@fails-components/webtransport 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +40 -109
- package/dist/lib/dom.d.ts +6 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/event-loop.d.ts +8 -3
- package/dist/lib/event-loop.d.ts.map +1 -1
- package/dist/lib/server.d.ts +3 -2
- package/dist/lib/server.d.ts.map +1 -1
- package/dist/lib/session.d.ts +66 -16
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/stream.d.ts +5 -5
- package/dist/lib/stream.d.ts.map +1 -1
- package/dist/lib/transport.d.ts.map +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/webtransport.d.ts +22 -0
- package/dist/lib/webtransport.d.ts.map +1 -1
- package/lib/dom.ts +7 -2
- package/lib/event-loop.js +13 -7
- package/lib/server.js +1 -1
- package/lib/session.js +51 -20
- package/lib/stream.js +26 -5
- package/lib/transport.js +3 -1
- package/lib/types.ts +1 -0
- package/lib/webtransport.js +31 -0
- package/package.json +2 -2
- package/platform/quiche/quic/core/io/socket_win.inc +3 -0
- package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +7 -0
- package/platform/quiche_platform_impl/quiche_export_impl.h +3 -9
- package/platform/quiche_platform_impl/quiche_server_stats_impl.h +1 -22
- package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +1 -4
- package/platform/quiche_platform_impl/quiche_time_utils_impl.h +1 -13
- package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +9 -0
- package/readme.md +3 -1
- package/src/http3client.cc +13 -29
- package/src/http3client.h +2 -6
- package/src/http3clientsession.cc +3 -1
- package/src/http3clientsession.h +9 -0
- package/src/http3clientstream.cc +17 -0
- package/src/http3clientstream.h +10 -0
- package/src/http3eventloop.cc +42 -55
- package/src/http3eventloop.h +2 -5
- package/src/http3serversession.cc +1 -136
- package/src/http3serversession.h +1 -72
- package/src/http3serverstream.cc +0 -49
- package/src/http3serverstream.h +0 -5
- package/src/http3wtsessionvisitor.cc +1 -1
- package/src/http3wtsessionvisitor.h +5 -37
- package/src/http3wtstreamvisitor.cc +2 -2
- package/test/bidirectional-streams.spec.js +1 -0
- package/test/datagrams.spec.js +1 -0
- package/test/unidirectional-streams.spec.js +1 -0
- package/platform/net/quiche/common/platform/impl/quiche_flags_impl.h +0 -12
- package/platform/poll.h +0 -2
- package/platform/quiche/quic/core/io/quic_poll_event_loop.h +0 -8
- package/platform/quiche_platform_impl/quic_testvalue_impl.h +0 -19
- package/platform/quiche_platform_impl/quic_udp_socket_winsock.cc +0 -732
- package/platform/quiche_platform_impl/quiche_time_utils_impl.cc +0 -43
- package/platform/quiche_platform_impl/socket_winsock.cc +0 -535
package/src/http3client.h
CHANGED
|
@@ -180,7 +180,6 @@ namespace quic
|
|
|
180
180
|
// Group 2.
|
|
181
181
|
bool response_headers_complete() const;
|
|
182
182
|
const spdy::Http2HeaderBlock *response_headers() const;
|
|
183
|
-
const spdy::Http2HeaderBlock *preliminary_headers() const;
|
|
184
183
|
int64_t response_size() const;
|
|
185
184
|
size_t bytes_read() const;
|
|
186
185
|
size_t bytes_written() const;
|
|
@@ -218,7 +217,7 @@ namespace quic
|
|
|
218
217
|
// QuicSpdyClientBase::Reponselistener
|
|
219
218
|
void OnCompleteResponse(
|
|
220
219
|
QuicStreamId id, const spdy::Http2HeaderBlock &response_headers,
|
|
221
|
-
const
|
|
220
|
+
const absl::string_view &response_body);
|
|
222
221
|
|
|
223
222
|
// From QuicClientPushPromiseIndex::Delegate
|
|
224
223
|
bool CheckVary(const spdy::Http2HeaderBlock &client_request,
|
|
@@ -321,8 +320,7 @@ namespace quic
|
|
|
321
320
|
PerStreamState(QuicRstStreamErrorCode stream_error, bool response_complete,
|
|
322
321
|
bool response_headers_complete,
|
|
323
322
|
const spdy::Http2HeaderBlock &response_headers,
|
|
324
|
-
const
|
|
325
|
-
const std::string &response,
|
|
323
|
+
const absl::string_view response,
|
|
326
324
|
const spdy::Http2HeaderBlock &response_trailers,
|
|
327
325
|
uint64_t bytes_read, uint64_t bytes_written,
|
|
328
326
|
int64_t response_body_size);
|
|
@@ -332,7 +330,6 @@ namespace quic
|
|
|
332
330
|
bool response_complete;
|
|
333
331
|
bool response_headers_complete;
|
|
334
332
|
spdy::Http2HeaderBlock response_headers;
|
|
335
|
-
spdy::Http2HeaderBlock preliminary_headers;
|
|
336
333
|
std::string response;
|
|
337
334
|
spdy::Http2HeaderBlock response_trailers;
|
|
338
335
|
uint64_t bytes_read;
|
|
@@ -398,7 +395,6 @@ namespace quic
|
|
|
398
395
|
|
|
399
396
|
bool response_complete_;
|
|
400
397
|
bool response_headers_complete_;
|
|
401
|
-
mutable spdy::Http2HeaderBlock preliminary_headers_;
|
|
402
398
|
mutable spdy::Http2HeaderBlock response_headers_;
|
|
403
399
|
|
|
404
400
|
// Parsed response trailers (if present), copied from the stream in OnClose.
|
|
@@ -37,9 +37,11 @@ Http3ClientSession::Http3ClientSession(
|
|
|
37
37
|
|
|
38
38
|
std::unique_ptr<QuicSpdyClientStream>
|
|
39
39
|
Http3ClientSession::CreateClientStream() {
|
|
40
|
-
|
|
40
|
+
auto stream = std::make_unique<Http3ClientStream>(
|
|
41
41
|
GetNextOutgoingBidirectionalStreamId(), this, BIDIRECTIONAL,
|
|
42
42
|
drop_response_body_);
|
|
43
|
+
stream->set_on_interim_headers(on_interim_headers_);
|
|
44
|
+
return stream;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
bool Http3ClientSession::ShouldNegotiateWebTransport() {
|
package/src/http3clientsession.h
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
#ifndef HTTP3_CLIENT_SESSION_H
|
|
12
12
|
#define HTTP3_CLIENT_SESSION_H
|
|
13
13
|
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <utility>
|
|
16
|
+
|
|
14
17
|
#include "quiche/quic/core/http/quic_spdy_client_session.h"
|
|
15
18
|
#include "src/http3clientstream.h"
|
|
16
19
|
|
|
@@ -37,7 +40,13 @@ class Http3ClientSession : public QuicSpdyClientSession {
|
|
|
37
40
|
bool ShouldNegotiateWebTransport() override;
|
|
38
41
|
HttpDatagramSupport LocalHttpDatagramSupport() override;
|
|
39
42
|
|
|
43
|
+
void set_on_interim_headers(
|
|
44
|
+
std::function<void(const spdy::Http2HeaderBlock&)> on_interim_headers) {
|
|
45
|
+
on_interim_headers_ = std::move(on_interim_headers);
|
|
46
|
+
}
|
|
47
|
+
|
|
40
48
|
private:
|
|
49
|
+
std::function<void(const spdy::Http2HeaderBlock&)> on_interim_headers_;
|
|
41
50
|
const bool drop_response_body_;
|
|
42
51
|
const bool enable_web_transport_;
|
|
43
52
|
};
|
package/src/http3clientstream.cc
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// found in the LICENSE file.
|
|
10
10
|
|
|
11
11
|
#include "src/http3clientstream.h"
|
|
12
|
+
#include "quiche/common/platform/api/quiche_logging.h"
|
|
12
13
|
|
|
13
14
|
namespace quic {
|
|
14
15
|
|
|
@@ -32,4 +33,20 @@ void Http3ClientStream::OnBodyAvailable() {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
bool Http3ClientStream::ParseAndValidateStatusCode() {
|
|
37
|
+
const size_t num_previous_interim_headers = preliminary_headers().size();
|
|
38
|
+
if (!QuicSpdyClientStream::ParseAndValidateStatusCode()) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// The base ParseAndValidateStatusCode() may have added a preliminary header.
|
|
42
|
+
if (preliminary_headers().size() > num_previous_interim_headers) {
|
|
43
|
+
QUICHE_DCHECK_EQ(preliminary_headers().size(),
|
|
44
|
+
num_previous_interim_headers + 1);
|
|
45
|
+
if (on_interim_headers_) {
|
|
46
|
+
on_interim_headers_(preliminary_headers().back());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
} // namespace quic
|
package/src/http3clientstream.h
CHANGED
|
@@ -23,7 +23,17 @@ class Http3ClientStream : public QuicSpdyClientStream {
|
|
|
23
23
|
drop_response_body_(drop_response_body) {}
|
|
24
24
|
void OnBodyAvailable() override;
|
|
25
25
|
|
|
26
|
+
void set_on_interim_headers(
|
|
27
|
+
std::function<void(const spdy::Http2HeaderBlock&)> on_interim_headers) {
|
|
28
|
+
on_interim_headers_ = std::move(on_interim_headers);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected:
|
|
32
|
+
bool ParseAndValidateStatusCode() override;
|
|
33
|
+
|
|
34
|
+
|
|
26
35
|
private:
|
|
36
|
+
std::function<void(const spdy::Http2HeaderBlock&)> on_interim_headers_;
|
|
27
37
|
const bool drop_response_body_;
|
|
28
38
|
};
|
|
29
39
|
|
package/src/http3eventloop.cc
CHANGED
|
@@ -17,19 +17,16 @@
|
|
|
17
17
|
#include "quiche/common/platform/api/quiche_reference_counted.h"
|
|
18
18
|
#include "quiche/quic/core/quic_default_clock.h"
|
|
19
19
|
#include "quiche/quic/bindings/quic_libevent.h"
|
|
20
|
+
#include "quiche/common/platform/api/quiche_command_line_flags.h"
|
|
21
|
+
|
|
22
|
+
#include "absl/log/initialize.h"
|
|
23
|
+
#include "absl/strings/string_view.h"
|
|
20
24
|
|
|
21
25
|
using namespace Napi;
|
|
22
26
|
|
|
23
27
|
namespace quic
|
|
24
28
|
{
|
|
25
29
|
|
|
26
|
-
#ifdef WIN32
|
|
27
|
-
|
|
28
|
-
bool initSockets();
|
|
29
|
-
bool destroySockets();
|
|
30
|
-
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
30
|
// hack since the header is faulty
|
|
34
31
|
QUICHE_NO_EXPORT QuicEventLoopFactory *GetDefaultEventLoop();
|
|
35
32
|
|
|
@@ -40,9 +37,6 @@ namespace quic
|
|
|
40
37
|
Http3EventLoop::~Http3EventLoop()
|
|
41
38
|
{
|
|
42
39
|
printf("Destructor eventloop\n");
|
|
43
|
-
#ifdef WIN32
|
|
44
|
-
destroySockets();
|
|
45
|
-
#endif
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
void Http3EventLoop::Init(Napi::Env env, Napi::Object exports)
|
|
@@ -61,7 +55,6 @@ namespace quic
|
|
|
61
55
|
Http3ClientJS::InitExports(env, exports);
|
|
62
56
|
Http3WTSessionJS::InitExports(env, exports, constr);
|
|
63
57
|
Http3WTStreamJS::InitExports(env, exports, constr);
|
|
64
|
-
Napi::ObjectReference *exportref = new Napi::ObjectReference();
|
|
65
58
|
|
|
66
59
|
env.SetInstanceData<Http3Constructors>(constr);
|
|
67
60
|
}
|
|
@@ -116,7 +109,7 @@ namespace quic
|
|
|
116
109
|
|
|
117
110
|
void Http3EventLoop::informAboutStream(bool incom, bool bidir, Http3WTSession *sessionobj, Http3WTStream *stream)
|
|
118
111
|
{
|
|
119
|
-
|
|
112
|
+
Http3ProgressReport report;
|
|
120
113
|
if (incom)
|
|
121
114
|
{
|
|
122
115
|
if (bidir)
|
|
@@ -147,7 +140,7 @@ namespace quic
|
|
|
147
140
|
|
|
148
141
|
void Http3EventLoop::informStreamRecvSignal(Http3WTStream *streamobj, WebTransportStreamError error_code, NetworkTask task)
|
|
149
142
|
{
|
|
150
|
-
|
|
143
|
+
Http3ProgressReport report;
|
|
151
144
|
report.type = Http3ProgressReport::StreamRecvSignal;
|
|
152
145
|
report.streamobj = streamobj;
|
|
153
146
|
report.wtscode = error_code;
|
|
@@ -158,7 +151,7 @@ namespace quic
|
|
|
158
151
|
|
|
159
152
|
void Http3EventLoop::informAboutStreamRead(Http3WTStream *streamobj, std::string *data, bool fin)
|
|
160
153
|
{
|
|
161
|
-
|
|
154
|
+
Http3ProgressReport report;
|
|
162
155
|
report.type = Http3ProgressReport::StreamRead;
|
|
163
156
|
report.streamobj = streamobj;
|
|
164
157
|
report.para = data;
|
|
@@ -169,7 +162,7 @@ namespace quic
|
|
|
169
162
|
|
|
170
163
|
void Http3EventLoop::informAboutStreamWrite(Http3WTStream *streamobj, Napi::ObjectReference *bufferhandle, bool success)
|
|
171
164
|
{
|
|
172
|
-
|
|
165
|
+
Http3ProgressReport report;
|
|
173
166
|
report.type = Http3ProgressReport::StreamWrite;
|
|
174
167
|
report.streamobj = streamobj;
|
|
175
168
|
report.bufferhandle = bufferhandle;
|
|
@@ -180,7 +173,7 @@ namespace quic
|
|
|
180
173
|
|
|
181
174
|
void Http3EventLoop::informAboutStreamNetworkFinish(Http3WTStream *streamobj, NetworkTask task)
|
|
182
175
|
{
|
|
183
|
-
|
|
176
|
+
Http3ProgressReport report;
|
|
184
177
|
report.type = Http3ProgressReport::StreamNetworkFinish;
|
|
185
178
|
report.streamobj = streamobj;
|
|
186
179
|
report.nettask = task;
|
|
@@ -190,7 +183,7 @@ namespace quic
|
|
|
190
183
|
|
|
191
184
|
void Http3EventLoop::informAboutStreamReset(Http3WTStream *streamobj)
|
|
192
185
|
{
|
|
193
|
-
|
|
186
|
+
Http3ProgressReport report;
|
|
194
187
|
report.type = Http3ProgressReport::StreamReset;
|
|
195
188
|
report.streamobj = streamobj;
|
|
196
189
|
if (progress_)
|
|
@@ -199,7 +192,7 @@ namespace quic
|
|
|
199
192
|
|
|
200
193
|
void Http3EventLoop::informDatagramReceived(Http3WTSession *sessionobj, absl::string_view datagram)
|
|
201
194
|
{
|
|
202
|
-
|
|
195
|
+
Http3ProgressReport report;
|
|
203
196
|
report.type = Http3ProgressReport::DatagramReceived;
|
|
204
197
|
report.sessionobj = sessionobj;
|
|
205
198
|
report.para = new std::string(datagram);
|
|
@@ -207,28 +200,19 @@ namespace quic
|
|
|
207
200
|
progress_->Send(&report, 1);
|
|
208
201
|
}
|
|
209
202
|
|
|
210
|
-
void Http3EventLoop::informDatagramSend(Http3WTSession *sessionobj)
|
|
203
|
+
void Http3EventLoop::informDatagramSend(Http3WTSession *sessionobj, Napi::ObjectReference *bufferhandle)
|
|
211
204
|
{
|
|
212
|
-
|
|
205
|
+
Http3ProgressReport report;
|
|
213
206
|
report.type = Http3ProgressReport::DatagramSend;
|
|
214
207
|
report.sessionobj = sessionobj;
|
|
215
|
-
if (progress_)
|
|
216
|
-
progress_->Send(&report, 1);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
void Http3EventLoop::informDatagramBufferFree(Napi::ObjectReference *bufferhandle)
|
|
220
|
-
{
|
|
221
|
-
struct Http3ProgressReport report;
|
|
222
|
-
report.type = Http3ProgressReport::DatagramBufferFree;
|
|
223
208
|
report.bufferhandle = bufferhandle;
|
|
224
|
-
|
|
225
209
|
if (progress_)
|
|
226
210
|
progress_->Send(&report, 1);
|
|
227
211
|
}
|
|
228
212
|
|
|
229
213
|
void Http3EventLoop::informUnref(LifetimeHelper *obj)
|
|
230
214
|
{
|
|
231
|
-
|
|
215
|
+
Http3ProgressReport report;
|
|
232
216
|
report.type = Http3ProgressReport::Unref;
|
|
233
217
|
report.obj = obj;
|
|
234
218
|
|
|
@@ -238,7 +222,7 @@ namespace quic
|
|
|
238
222
|
|
|
239
223
|
void Http3EventLoop::informAboutClientConnected(Http3Client *client, bool success)
|
|
240
224
|
{
|
|
241
|
-
|
|
225
|
+
Http3ProgressReport report;
|
|
242
226
|
report.type = Http3ProgressReport::ClientConnected;
|
|
243
227
|
report.clientobj = client;
|
|
244
228
|
report.success = success;
|
|
@@ -248,7 +232,7 @@ namespace quic
|
|
|
248
232
|
|
|
249
233
|
void Http3EventLoop::informClientWebtransportSupport(Http3Client *client)
|
|
250
234
|
{
|
|
251
|
-
|
|
235
|
+
Http3ProgressReport report;
|
|
252
236
|
report.type = Http3ProgressReport::ClientWebTransportSupport;
|
|
253
237
|
report.clientobj = client;
|
|
254
238
|
if (progress_)
|
|
@@ -257,7 +241,7 @@ namespace quic
|
|
|
257
241
|
|
|
258
242
|
void Http3EventLoop::informAboutNewSessionRequest(Http3Server *server, WebTransportSession *session, spdy::Http2HeaderBlock *reqheadcopy, WebTransportRespPromisePtr promise)
|
|
259
243
|
{
|
|
260
|
-
|
|
244
|
+
Http3ProgressReport report;
|
|
261
245
|
report.type = Http3ProgressReport::NewSessionRequest;
|
|
262
246
|
report.webtsession = session;
|
|
263
247
|
report.serverobj = server;
|
|
@@ -269,7 +253,7 @@ namespace quic
|
|
|
269
253
|
|
|
270
254
|
void Http3EventLoop::informAboutNewSession(Http3Server *server, Http3WTSession *session, absl::string_view path, Napi::Reference<Napi::Value> *header)
|
|
271
255
|
{
|
|
272
|
-
|
|
256
|
+
Http3ProgressReport report;
|
|
273
257
|
report.type = Http3ProgressReport::NewSession;
|
|
274
258
|
report.serverobj = server;
|
|
275
259
|
report.session = session;
|
|
@@ -281,7 +265,7 @@ namespace quic
|
|
|
281
265
|
|
|
282
266
|
void Http3EventLoop::informNewClientSession(Http3Client *client, Http3WTSession *session)
|
|
283
267
|
{
|
|
284
|
-
|
|
268
|
+
Http3ProgressReport report;
|
|
285
269
|
report.type = Http3ProgressReport::NewClientSession;
|
|
286
270
|
report.clientobj = client;
|
|
287
271
|
report.session = session;
|
|
@@ -292,7 +276,7 @@ namespace quic
|
|
|
292
276
|
void Http3EventLoop::informSessionClosed(Http3WTSession *sessionobj, WebTransportSessionError error_code,
|
|
293
277
|
absl::string_view error_message)
|
|
294
278
|
{
|
|
295
|
-
|
|
279
|
+
Http3ProgressReport report;
|
|
296
280
|
report.type = Http3ProgressReport::SessionClosed;
|
|
297
281
|
report.sessionobj = sessionobj;
|
|
298
282
|
report.para = new std::string(error_message);
|
|
@@ -303,7 +287,7 @@ namespace quic
|
|
|
303
287
|
|
|
304
288
|
void Http3EventLoop::informSessionReady(Http3WTSession *sessionobj)
|
|
305
289
|
{
|
|
306
|
-
|
|
290
|
+
Http3ProgressReport report;
|
|
307
291
|
report.type = Http3ProgressReport::SessionReady;
|
|
308
292
|
report.sessionobj = sessionobj;
|
|
309
293
|
if (progress_)
|
|
@@ -312,7 +296,7 @@ namespace quic
|
|
|
312
296
|
|
|
313
297
|
void Http3EventLoop::informServerStatus(Http3Server *serverobj, NetworkStatus status, ServerStatusDetails *details)
|
|
314
298
|
{
|
|
315
|
-
|
|
299
|
+
Http3ProgressReport report;
|
|
316
300
|
report.type = Http3ProgressReport::ServerStatus;
|
|
317
301
|
report.serverobj = serverobj;
|
|
318
302
|
report.status = status;
|
|
@@ -534,12 +518,6 @@ namespace quic
|
|
|
534
518
|
cbstream_.Call({retObj});
|
|
535
519
|
}
|
|
536
520
|
|
|
537
|
-
void Http3EventLoop::processDatagramBufferFree(Napi::ObjectReference *bufferhandle)
|
|
538
|
-
{
|
|
539
|
-
bufferhandle->Unref(); // release the outgoing buffer
|
|
540
|
-
delete bufferhandle; // free the handle object
|
|
541
|
-
}
|
|
542
|
-
|
|
543
521
|
void Http3EventLoop::processDatagramReceived(Http3WTSession *sessionobj, std::string *datagram)
|
|
544
522
|
{
|
|
545
523
|
if (!checkQw())
|
|
@@ -565,8 +543,10 @@ namespace quic
|
|
|
565
543
|
cbsession_.Call({retObj});
|
|
566
544
|
}
|
|
567
545
|
|
|
568
|
-
void Http3EventLoop::processDatagramSend(Http3WTSession *sessionobj)
|
|
546
|
+
void Http3EventLoop::processDatagramSend(Http3WTSession *sessionobj, Napi::ObjectReference *bufferhandle)
|
|
569
547
|
{
|
|
548
|
+
bufferhandle->Unref(); // release the outgoing buffer
|
|
549
|
+
delete bufferhandle; // free the handle object
|
|
570
550
|
if (!checkQw())
|
|
571
551
|
return;
|
|
572
552
|
HandleScope scope(qw_->Env());
|
|
@@ -867,12 +847,7 @@ namespace quic
|
|
|
867
847
|
break;
|
|
868
848
|
case Http3ProgressReport::DatagramSend:
|
|
869
849
|
{
|
|
870
|
-
processDatagramSend(cur.sessionobj);
|
|
871
|
-
}
|
|
872
|
-
break;
|
|
873
|
-
case Http3ProgressReport::DatagramBufferFree:
|
|
874
|
-
{
|
|
875
|
-
processDatagramBufferFree(cur.bufferhandle);
|
|
850
|
+
processDatagramSend(cur.sessionobj, cur.bufferhandle);
|
|
876
851
|
}
|
|
877
852
|
break;
|
|
878
853
|
case Http3ProgressReport::Unref:
|
|
@@ -891,10 +866,8 @@ namespace quic
|
|
|
891
866
|
progress_(nullptr),
|
|
892
867
|
quic_event_loop_(GetDefaultEventLoop()->Create(QuicDefaultClock::Get()))
|
|
893
868
|
{
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
#endif
|
|
897
|
-
|
|
869
|
+
std::vector<std::string> quiche_cmd_line;
|
|
870
|
+
quiche_cmd_line.push_back(std::string("webtransport.node"));
|
|
898
871
|
if (!info[0].IsUndefined() /*|| info[1].IsFunction()*/)
|
|
899
872
|
{
|
|
900
873
|
Napi::Object lobj = info[0].ToObject();
|
|
@@ -945,12 +918,26 @@ namespace quic
|
|
|
945
918
|
Napi::Error::New(Env(), "No session callback").ThrowAsJavaScriptException();
|
|
946
919
|
return;
|
|
947
920
|
}
|
|
921
|
+
quiche_cmd_line.push_back(std::string("-v"));
|
|
922
|
+
if (lobj.Has("quicheLogVerbose") && lobj.Get("quicheLogVerbose").IsFunction())
|
|
923
|
+
{
|
|
924
|
+
Napi::Value verboseValue = (lobj).Get("quicheLogVerbose");
|
|
925
|
+
quiche_cmd_line.push_back(verboseValue.ToString().Utf8Value());
|
|
926
|
+
} else {
|
|
927
|
+
quiche_cmd_line.push_back(std::string("-1"));
|
|
928
|
+
}
|
|
948
929
|
}
|
|
949
930
|
else
|
|
950
931
|
{
|
|
951
932
|
Napi::Error::New(Env(), "Callback not passed to Http3EventLoop internal").ThrowAsJavaScriptException();
|
|
952
933
|
return;
|
|
953
934
|
}
|
|
935
|
+
std::vector<const char*> quiche_cmd_line_char;
|
|
936
|
+
for (auto cur= quiche_cmd_line.begin(); cur != quiche_cmd_line.end(); cur++) {
|
|
937
|
+
quiche_cmd_line_char.push_back((*cur).c_str());
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
quiche::QuicheParseCommandLineFlags("No use instruction.", quiche_cmd_line.size(), &(*quiche_cmd_line_char.begin()));
|
|
954
941
|
}
|
|
955
942
|
|
|
956
943
|
void Http3EventLoop::startEventLoop(const Napi::CallbackInfo &info)
|
package/src/http3eventloop.h
CHANGED
|
@@ -93,7 +93,6 @@ namespace quic
|
|
|
93
93
|
StreamNetworkFinish,
|
|
94
94
|
DatagramReceived,
|
|
95
95
|
DatagramSend,
|
|
96
|
-
DatagramBufferFree,
|
|
97
96
|
Unref
|
|
98
97
|
} type;
|
|
99
98
|
union
|
|
@@ -216,8 +215,7 @@ namespace quic
|
|
|
216
215
|
void informAboutStreamNetworkFinish(Http3WTStream *streamobj, NetworkTask task);
|
|
217
216
|
|
|
218
217
|
void informDatagramReceived(Http3WTSession *sessionobj, absl::string_view datagram);
|
|
219
|
-
void
|
|
220
|
-
void informDatagramSend(Http3WTSession *sessionobj);
|
|
218
|
+
void informDatagramSend(Http3WTSession *sessionobj, Napi::ObjectReference *bufferhandle);
|
|
221
219
|
|
|
222
220
|
void informUnref(LifetimeHelper *obj);
|
|
223
221
|
|
|
@@ -282,8 +280,7 @@ namespace quic
|
|
|
282
280
|
void processStreamNetworkFinish(Http3WTStream *streamobj, NetworkTask task);
|
|
283
281
|
|
|
284
282
|
void processDatagramReceived(Http3WTSession *sessionobj, std::string *datagram);
|
|
285
|
-
void processDatagramSend(Http3WTSession *sessionobj);
|
|
286
|
-
void processDatagramBufferFree(Napi::ObjectReference *bufferhandle);
|
|
283
|
+
void processDatagramSend(Http3WTSession *sessionobj, Napi::ObjectReference *bufferhandle);
|
|
287
284
|
|
|
288
285
|
bool shutDownEventLoopInt();
|
|
289
286
|
|
|
@@ -34,14 +34,12 @@ namespace quic
|
|
|
34
34
|
Http3ServerBackend *http3_server_backend)
|
|
35
35
|
: QuicServerSessionBase(config, supported_versions, connection, visitor,
|
|
36
36
|
helper, crypto_config, compressed_certs_cache),
|
|
37
|
-
highest_promised_stream_id_(
|
|
38
|
-
QuicUtils::GetInvalidStreamId(connection->transport_version())),
|
|
39
37
|
http3_server_backend_(http3_server_backend)
|
|
40
38
|
{
|
|
41
39
|
QUICHE_DCHECK(http3_server_backend_);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
Http3ServerSession::~Http3ServerSession() {
|
|
42
|
+
Http3ServerSession::~Http3ServerSession() { DeleteConnection(); }
|
|
45
43
|
|
|
46
44
|
std::unique_ptr<QuicCryptoServerStreamBase>
|
|
47
45
|
Http3ServerSession::CreateQuicCryptoServerStream(
|
|
@@ -122,137 +120,4 @@ namespace quic
|
|
|
122
120
|
ActivateStream(absl::WrapUnique(stream));
|
|
123
121
|
return stream;
|
|
124
122
|
}
|
|
125
|
-
|
|
126
|
-
void Http3ServerSession::HandleFrameOnNonexistentOutgoingStream(
|
|
127
|
-
QuicStreamId stream_id)
|
|
128
|
-
{
|
|
129
|
-
// If this stream is a promised but not created stream (stream_id within the
|
|
130
|
-
// range of next_outgoing_stream_id_ and highes_promised_stream_id_),
|
|
131
|
-
// connection shouldn't be closed.
|
|
132
|
-
// Otherwise behave in the same way as base class.
|
|
133
|
-
if (highest_promised_stream_id_ ==
|
|
134
|
-
QuicUtils::GetInvalidStreamId(transport_version()) ||
|
|
135
|
-
stream_id > highest_promised_stream_id_)
|
|
136
|
-
{
|
|
137
|
-
QuicSession::HandleFrameOnNonexistentOutgoingStream(stream_id);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
void Http3ServerSession::HandleRstOnValidNonexistentStream(
|
|
142
|
-
const QuicRstStreamFrame &frame)
|
|
143
|
-
{
|
|
144
|
-
QuicSession::HandleRstOnValidNonexistentStream(frame);
|
|
145
|
-
if (!IsClosedStream(frame.stream_id))
|
|
146
|
-
{
|
|
147
|
-
// If a nonexistent stream is not a closed stream and still valid, it must
|
|
148
|
-
// be a locally preserved stream. Resetting this kind of stream means
|
|
149
|
-
// cancelling the promised server push.
|
|
150
|
-
// Since PromisedStreamInfo are queued in sequence, the corresponding
|
|
151
|
-
// index for it in promised_streams_ can be calculated.
|
|
152
|
-
QuicStreamId next_stream_id = next_outgoing_unidirectional_stream_id();
|
|
153
|
-
if ((!version().HasIetfQuicFrames() ||
|
|
154
|
-
!QuicUtils::IsBidirectionalStreamId(frame.stream_id, version())) &&
|
|
155
|
-
frame.stream_id >= next_stream_id)
|
|
156
|
-
{
|
|
157
|
-
size_t index = (frame.stream_id - next_stream_id) /
|
|
158
|
-
QuicUtils::StreamIdDelta(transport_version());
|
|
159
|
-
if (index <= promised_streams_.size())
|
|
160
|
-
{
|
|
161
|
-
promised_streams_[index].is_cancelled = true;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
control_frame_manager().WriteOrBufferRstStream(
|
|
165
|
-
frame.stream_id,
|
|
166
|
-
QuicResetStreamError::FromInternal(QUIC_RST_ACKNOWLEDGEMENT), 0);
|
|
167
|
-
connection()->OnStreamReset(frame.stream_id, QUIC_RST_ACKNOWLEDGEMENT);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/*
|
|
172
|
-
spdy::Http2HeaderBlock Http3ServerSession::SynthesizePushRequestHeaders(
|
|
173
|
-
std::string request_url, QuicBackendResponse::ServerPushInfo resource,
|
|
174
|
-
const spdy::Http2HeaderBlock& original_request_headers) {
|
|
175
|
-
QuicUrl push_request_url = resource.request_url;
|
|
176
|
-
|
|
177
|
-
spdy::Http2HeaderBlock spdy_headers = original_request_headers.Clone();
|
|
178
|
-
// :authority could be different from original request.
|
|
179
|
-
spdy_headers[":authority"] = push_request_url.host();
|
|
180
|
-
spdy_headers[":path"] = push_request_url.path();
|
|
181
|
-
// Push request always use GET.
|
|
182
|
-
spdy_headers[":method"] = "GET";
|
|
183
|
-
spdy_headers["referer"] = request_url;
|
|
184
|
-
spdy_headers[":scheme"] = push_request_url.scheme();
|
|
185
|
-
// It is not possible to push a response to a request that includes a request
|
|
186
|
-
// body.
|
|
187
|
-
spdy_headers["content-length"] = "0";
|
|
188
|
-
// Remove "host" field as push request is a directly generated HTTP2 request
|
|
189
|
-
// which should use ":authority" instead of "host".
|
|
190
|
-
spdy_headers.erase("host");
|
|
191
|
-
return spdy_headers;
|
|
192
|
-
}*/
|
|
193
|
-
|
|
194
|
-
/*
|
|
195
|
-
void Http3ServerSession::SendPushPromise(QuicStreamId original_stream_id,
|
|
196
|
-
QuicStreamId promised_stream_id,
|
|
197
|
-
spdy::Http2HeaderBlock headers) {
|
|
198
|
-
QUIC_DLOG(INFO) << "stream " << original_stream_id
|
|
199
|
-
<< " send PUSH_PROMISE for promised stream "
|
|
200
|
-
<< promised_stream_id;
|
|
201
|
-
WritePushPromise(original_stream_id, promised_stream_id, std::move(headers));
|
|
202
|
-
}*/
|
|
203
|
-
|
|
204
|
-
void Http3ServerSession::HandlePromisedPushRequests()
|
|
205
|
-
{
|
|
206
|
-
while (!promised_streams_.empty() &&
|
|
207
|
-
ShouldCreateOutgoingUnidirectionalStream())
|
|
208
|
-
{
|
|
209
|
-
PromisedStreamInfo &promised_info = promised_streams_.front();
|
|
210
|
-
QUICHE_DCHECK_EQ(next_outgoing_unidirectional_stream_id(),
|
|
211
|
-
promised_info.stream_id);
|
|
212
|
-
|
|
213
|
-
if (promised_info.is_cancelled)
|
|
214
|
-
{
|
|
215
|
-
// This stream has been reset by client. Skip this stream id.
|
|
216
|
-
promised_streams_.pop_front();
|
|
217
|
-
GetNextOutgoingUnidirectionalStreamId();
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
Http3ServerStream *promised_stream =
|
|
222
|
-
static_cast<Http3ServerStream *>(
|
|
223
|
-
CreateOutgoingUnidirectionalStream());
|
|
224
|
-
QUICHE_DCHECK_NE(promised_stream, nullptr);
|
|
225
|
-
QUICHE_DCHECK_EQ(promised_info.stream_id, promised_stream->id());
|
|
226
|
-
QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id();
|
|
227
|
-
|
|
228
|
-
promised_stream->SetPriority(promised_info.priority);
|
|
229
|
-
|
|
230
|
-
spdy::Http2HeaderBlock request_headers(
|
|
231
|
-
std::move(promised_info.request_headers));
|
|
232
|
-
|
|
233
|
-
promised_streams_.pop_front();
|
|
234
|
-
promised_stream->PushResponse(std::move(request_headers));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
void Http3ServerSession::OnCanCreateNewOutgoingStream(
|
|
239
|
-
bool unidirectional)
|
|
240
|
-
{
|
|
241
|
-
QuicSpdySession::OnCanCreateNewOutgoingStream(unidirectional);
|
|
242
|
-
if (unidirectional)
|
|
243
|
-
{
|
|
244
|
-
HandlePromisedPushRequests();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
void Http3ServerSession::MaybeInitializeHttp3UnidirectionalStreams()
|
|
249
|
-
{
|
|
250
|
-
size_t previous_static_stream_count = num_static_streams();
|
|
251
|
-
QuicSpdySession::MaybeInitializeHttp3UnidirectionalStreams();
|
|
252
|
-
size_t current_static_stream_count = num_static_streams();
|
|
253
|
-
QUICHE_DCHECK_GE(current_static_stream_count, previous_static_stream_count);
|
|
254
|
-
highest_promised_stream_id_ +=
|
|
255
|
-
QuicUtils::StreamIdDelta(transport_version()) *
|
|
256
|
-
(current_static_stream_count - previous_static_stream_count);
|
|
257
|
-
}
|
|
258
123
|
} // namespace quic
|