@fails-components/webtransport-transport-http3-quiche 1.1.3 → 1.2.0
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 +51 -50
- package/package.json +5 -5
- package/src/http3backendresponse.cc +1 -1
- package/src/http3backendresponse.h +13 -13
- package/src/http3client.cc +57 -25
- package/src/http3client.h +19 -17
- package/src/http3clientsession.cc +1 -1
- package/src/http3clientsession.h +2 -2
- package/src/http3clientstream.h +2 -2
- package/src/http3server.cc +10 -1
- package/src/http3server.h +1 -1
- package/src/http3serverbackend.cc +3 -3
- package/src/http3serverbackend.h +3 -3
- package/src/http3serversession.cc +4 -1
- package/src/http3serverstream.cc +11 -11
- package/src/http3serverstream.h +7 -7
- package/src/http3wtsessionvisitor.cc +35 -16
- package/src/http3wtsessionvisitor.h +76 -14
- package/src/http3wtstreamvisitor.cc +10 -0
- package/src/http3wtstreamvisitor.h +30 -1
- package/src/librarymain.cc +2 -0
- package/platform/quiche_platform_impl/quiche_mutex_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_prefetch_impl.h +0 -11
package/src/http3client.h
CHANGED
|
@@ -121,7 +121,8 @@ namespace quic
|
|
|
121
121
|
std::unique_ptr<ProofVerifier> proof_verifier,
|
|
122
122
|
std::unique_ptr<SessionCache> session_cache,
|
|
123
123
|
std::unique_ptr<QuicConnectionHelperInterface> helper,
|
|
124
|
-
QuicConfig config
|
|
124
|
+
QuicConfig config,
|
|
125
|
+
const std::vector<std::string>& protocols);
|
|
125
126
|
|
|
126
127
|
~Http3Client() override;
|
|
127
128
|
|
|
@@ -157,12 +158,12 @@ namespace quic
|
|
|
157
158
|
|
|
158
159
|
// Sends a request containing |headers| and |body| and returns the number of
|
|
159
160
|
// bytes sent (the size of the serialized request headers and body).
|
|
160
|
-
void SendMessageAsync(const
|
|
161
|
+
void SendMessageAsync(const quiche::HttpHeaderBlock &headers,
|
|
161
162
|
absl::string_view body);
|
|
162
163
|
// Sends a request containing |headers| and |body| with the fin bit set to
|
|
163
164
|
// |fin| and returns the number of bytes sent (the size of the serialized
|
|
164
165
|
// request headers and body).
|
|
165
|
-
void SendMessageAsync(const
|
|
166
|
+
void SendMessageAsync(const quiche::HttpHeaderBlock &headers,
|
|
166
167
|
absl::string_view body, bool fin);
|
|
167
168
|
|
|
168
169
|
void SendConnectivityProbing();
|
|
@@ -193,13 +194,13 @@ namespace quic
|
|
|
193
194
|
// is received. 2) returns state of the oldest active stream which have
|
|
194
195
|
// received partial response (if any).
|
|
195
196
|
// Group 1.
|
|
196
|
-
const
|
|
197
|
+
const quiche::HttpHeaderBlock &response_trailers() const;
|
|
197
198
|
bool response_complete() const;
|
|
198
199
|
int64_t response_body_size() const;
|
|
199
200
|
const std::string &response_body() const;
|
|
200
201
|
// Group 2.
|
|
201
202
|
bool response_headers_complete() const;
|
|
202
|
-
const
|
|
203
|
+
const quiche::HttpHeaderBlock *response_headers() const;
|
|
203
204
|
int64_t response_size() const;
|
|
204
205
|
size_t bytes_read() const;
|
|
205
206
|
size_t bytes_written() const;
|
|
@@ -214,7 +215,7 @@ namespace quic
|
|
|
214
215
|
|
|
215
216
|
// QuicSpdyClientBase::Reponselistener
|
|
216
217
|
void OnCompleteResponse(
|
|
217
|
-
QuicStreamId id, const
|
|
218
|
+
QuicStreamId id, const quiche::HttpHeaderBlock &response_headers,
|
|
218
219
|
const absl::string_view &response_body);
|
|
219
220
|
|
|
220
221
|
// Returns nullptr if the maximum number of streams have already been created.
|
|
@@ -226,7 +227,7 @@ namespace quic
|
|
|
226
227
|
// stores the request in case it needs to be resent. If |headers| is
|
|
227
228
|
// null, only the body will be sent on the stream.
|
|
228
229
|
void GetOrCreateStreamAndSendRequest(
|
|
229
|
-
const
|
|
230
|
+
const quiche::HttpHeaderBlock *headers, absl::string_view body, bool fin);
|
|
230
231
|
|
|
231
232
|
QuicRstStreamErrorCode stream_error() { return stream_error_; }
|
|
232
233
|
QuicErrorCode connection_error() const;
|
|
@@ -263,7 +264,7 @@ namespace quic
|
|
|
263
264
|
// request. If |uri| is a relative URL, the QuicServerId will be
|
|
264
265
|
// use to specify the authority.
|
|
265
266
|
bool PopulateHeaderBlockFromUrl(const std::string &uri,
|
|
266
|
-
|
|
267
|
+
quiche::HttpHeaderBlock *headers);
|
|
267
268
|
|
|
268
269
|
QuicSpdyClientStream *latest_created_stream()
|
|
269
270
|
{
|
|
@@ -291,7 +292,7 @@ namespace quic
|
|
|
291
292
|
{
|
|
292
293
|
public:
|
|
293
294
|
Http3ClientDataToResend(
|
|
294
|
-
std::unique_ptr<
|
|
295
|
+
std::unique_ptr<quiche::HttpHeaderBlock> headers, absl::string_view body,
|
|
295
296
|
bool fin, Http3Client *client);
|
|
296
297
|
|
|
297
298
|
~Http3ClientDataToResend();
|
|
@@ -299,7 +300,7 @@ namespace quic
|
|
|
299
300
|
void Resend();
|
|
300
301
|
|
|
301
302
|
protected:
|
|
302
|
-
std::unique_ptr<
|
|
303
|
+
std::unique_ptr<quiche::HttpHeaderBlock> headers_;
|
|
303
304
|
absl::string_view body_;
|
|
304
305
|
bool fin_;
|
|
305
306
|
Http3Client *client_;
|
|
@@ -311,9 +312,9 @@ namespace quic
|
|
|
311
312
|
PerStreamState(const PerStreamState &other);
|
|
312
313
|
PerStreamState(QuicRstStreamErrorCode stream_error, bool response_complete,
|
|
313
314
|
bool response_headers_complete,
|
|
314
|
-
const
|
|
315
|
+
const quiche::HttpHeaderBlock &response_headers,
|
|
315
316
|
const absl::string_view response,
|
|
316
|
-
const
|
|
317
|
+
const quiche::HttpHeaderBlock &response_trailers,
|
|
317
318
|
uint64_t bytes_read, uint64_t bytes_written,
|
|
318
319
|
int64_t response_body_size);
|
|
319
320
|
~PerStreamState();
|
|
@@ -321,9 +322,9 @@ namespace quic
|
|
|
321
322
|
QuicRstStreamErrorCode stream_error;
|
|
322
323
|
bool response_complete;
|
|
323
324
|
bool response_headers_complete;
|
|
324
|
-
|
|
325
|
+
quiche::HttpHeaderBlock response_headers;
|
|
325
326
|
std::string response;
|
|
326
|
-
|
|
327
|
+
quiche::HttpHeaderBlock response_trailers;
|
|
327
328
|
uint64_t bytes_read;
|
|
328
329
|
uint64_t bytes_written;
|
|
329
330
|
int64_t response_body_size;
|
|
@@ -381,10 +382,10 @@ namespace quic
|
|
|
381
382
|
|
|
382
383
|
bool response_complete_;
|
|
383
384
|
bool response_headers_complete_;
|
|
384
|
-
mutable
|
|
385
|
+
mutable quiche::HttpHeaderBlock response_headers_;
|
|
385
386
|
|
|
386
387
|
// Parsed response trailers (if present), copied from the stream in OnClose.
|
|
387
|
-
|
|
388
|
+
quiche::HttpHeaderBlock response_trailers_;
|
|
388
389
|
|
|
389
390
|
QuicStreamPriority priority_;
|
|
390
391
|
std::string response_;
|
|
@@ -504,7 +505,7 @@ namespace quic
|
|
|
504
505
|
// preliminary 100 Continue HTTP/2 headers from most recent response, if any.
|
|
505
506
|
std::string preliminary_response_headers_;
|
|
506
507
|
// HTTP/2 headers from most recent response.
|
|
507
|
-
|
|
508
|
+
quiche::HttpHeaderBlock latest_response_header_block_;
|
|
508
509
|
// Body of most recent response.
|
|
509
510
|
std::string latest_response_body_;
|
|
510
511
|
// HTTP/2 trailers from most recent response.
|
|
@@ -528,6 +529,7 @@ namespace quic
|
|
|
528
529
|
bool connectionrecheck_;
|
|
529
530
|
|
|
530
531
|
std::queue<std::function<void(QuicSpdyClientStream *)>> finish_stream_open_;
|
|
532
|
+
std::vector<std::string> protocols_;
|
|
531
533
|
};
|
|
532
534
|
|
|
533
535
|
} // namespace quic
|
|
@@ -34,7 +34,7 @@ namespace quic
|
|
|
34
34
|
bool drop_response_body,
|
|
35
35
|
bool enable_web_transport)
|
|
36
36
|
: QuicSpdyClientSession(config, supported_versions, connection, server_id,
|
|
37
|
-
crypto_config),
|
|
37
|
+
crypto_config, QuicPriorityType::kWebTransport),
|
|
38
38
|
drop_response_body_(drop_response_body),
|
|
39
39
|
enable_web_transport_(enable_web_transport) {}
|
|
40
40
|
|
package/src/http3clientsession.h
CHANGED
|
@@ -47,13 +47,13 @@ namespace quic
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
void set_on_interim_headers(
|
|
50
|
-
std::function<void(const
|
|
50
|
+
std::function<void(const quiche::HttpHeaderBlock &)> on_interim_headers)
|
|
51
51
|
{
|
|
52
52
|
on_interim_headers_ = std::move(on_interim_headers);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
private:
|
|
56
|
-
std::function<void(const
|
|
56
|
+
std::function<void(const quiche::HttpHeaderBlock &)> on_interim_headers_;
|
|
57
57
|
const bool drop_response_body_;
|
|
58
58
|
const bool enable_web_transport_;
|
|
59
59
|
absl::flat_hash_map<QuicStreamId, webtransport::SessionVisitor *> svisitors_;
|
package/src/http3clientstream.h
CHANGED
|
@@ -24,7 +24,7 @@ class Http3ClientStream : public QuicSpdyClientStream {
|
|
|
24
24
|
void OnBodyAvailable() override;
|
|
25
25
|
|
|
26
26
|
void set_on_interim_headers(
|
|
27
|
-
std::function<void(const
|
|
27
|
+
std::function<void(const quiche::HttpHeaderBlock&)> on_interim_headers) {
|
|
28
28
|
on_interim_headers_ = std::move(on_interim_headers);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ class Http3ClientStream : public QuicSpdyClientStream {
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
private:
|
|
36
|
-
std::function<void(const
|
|
36
|
+
std::function<void(const quiche::HttpHeaderBlock&)> on_interim_headers_;
|
|
37
37
|
const bool drop_response_body_;
|
|
38
38
|
};
|
|
39
39
|
|
package/src/http3server.cc
CHANGED
|
@@ -426,7 +426,7 @@ namespace quic
|
|
|
426
426
|
.Call(objVal, {retObj});
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
void Http3ServerJS::processNewSessionRequest(WebTransportSession *session, const
|
|
429
|
+
void Http3ServerJS::processNewSessionRequest(WebTransportSession *session, const quiche::HttpHeaderBlock &reqhead, WebTransportRespPromisePtr promise)
|
|
430
430
|
{
|
|
431
431
|
Napi::HandleScope scope(Env());
|
|
432
432
|
|
|
@@ -494,6 +494,7 @@ namespace quic
|
|
|
494
494
|
int status = -1;
|
|
495
495
|
std::string path = "";
|
|
496
496
|
Napi::Object lobj = info[0].ToObject();
|
|
497
|
+
std::string selectedProtocol = "";
|
|
497
498
|
if (!lobj.IsEmpty())
|
|
498
499
|
{
|
|
499
500
|
if (lobj.Has("status") && !(lobj).Get("status").IsEmpty())
|
|
@@ -552,6 +553,11 @@ namespace quic
|
|
|
552
553
|
NAPI_THROW_IF_FAILED(Env(), status, Reference<Napi::Value>());
|
|
553
554
|
userDataValue = new Napi::Reference<Napi::Value>(Env(), ref);
|
|
554
555
|
}
|
|
556
|
+
if (lobj.Has("selectedProtocol") && !(lobj).Get("selectedProtocol").IsUndefined())
|
|
557
|
+
{
|
|
558
|
+
Napi::Value selectedProtocolValue = (lobj).Get("selectedProtocol");
|
|
559
|
+
selectedProtocol = selectedProtocolValue.ToString().Utf8Value();
|
|
560
|
+
}
|
|
555
561
|
}
|
|
556
562
|
if (status != 200)
|
|
557
563
|
{
|
|
@@ -563,6 +569,9 @@ namespace quic
|
|
|
563
569
|
{
|
|
564
570
|
std::unique_ptr<Http3ServerBackend::WebTransportResponse> response = std::make_unique<Http3ServerBackend::WebTransportResponse>();
|
|
565
571
|
response->response_headers[":status"] = std::to_string(status);
|
|
572
|
+
if (selectedProtocol != "") {
|
|
573
|
+
response->response_headers["wt-protocol"] = selectedProtocol;
|
|
574
|
+
}
|
|
566
575
|
Http3WTSession *wtsession = new Http3WTSession();
|
|
567
576
|
wtsession->init(session);
|
|
568
577
|
response->visitor =
|
package/src/http3server.h
CHANGED
|
@@ -85,7 +85,7 @@ namespace quic
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
void processNewSession(Http3WTSession *session, const std::string &path, Napi::Reference<Napi::Value> *header, Napi::Reference<Napi::Value> *userData);
|
|
88
|
-
void processNewSessionRequest(WebTransportSession *session, const
|
|
88
|
+
void processNewSessionRequest(WebTransportSession *session, const quiche::HttpHeaderBlock &reqheadcopy, WebTransportRespPromisePtr promise);
|
|
89
89
|
|
|
90
90
|
protected:
|
|
91
91
|
std::unique_ptr<Http3Server> server_;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
#include "quiche/common/platform/api/quiche_file_utils.h"
|
|
26
26
|
#include "quiche/common/quiche_text_utils.h"
|
|
27
27
|
|
|
28
|
-
using
|
|
28
|
+
using quiche::HttpHeaderBlock;
|
|
29
29
|
|
|
30
30
|
namespace quic
|
|
31
31
|
{
|
|
@@ -34,7 +34,7 @@ namespace quic
|
|
|
34
34
|
void QuicMemoryCacheBackend::GenerateDynamicResponses() {
|
|
35
35
|
QuicWriterMutexLock lock(&response_mutex_);
|
|
36
36
|
// Add a generate bytes response.
|
|
37
|
-
|
|
37
|
+
quiche::HttpHeaderBlock response_headers;
|
|
38
38
|
response_headers[":status"] = "200";
|
|
39
39
|
generate_bytes_response_ = std::make_unique<QuicBackendResponse>();
|
|
40
40
|
generate_bytes_response_->set_headers(std::move(response_headers));
|
|
@@ -45,7 +45,7 @@ namespace quic
|
|
|
45
45
|
|
|
46
46
|
Http3ServerBackend::WebTransportRespPromisePtr
|
|
47
47
|
Http3ServerBackend::ProcessWebTransportRequest(
|
|
48
|
-
const
|
|
48
|
+
const quiche::HttpHeaderBlock &request_headers,
|
|
49
49
|
WebTransportSession *session)
|
|
50
50
|
{
|
|
51
51
|
WebTransportRespPromisePtr promise = std::make_shared<WebTransportRespPromise>();
|
package/src/http3serverbackend.h
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
#include "quiche/quic/core/quic_types.h"
|
|
17
17
|
#include "quiche/quic/core/web_transport_interface.h"
|
|
18
|
-
#include "quiche/
|
|
18
|
+
#include "quiche/common/http/http_header_block.h"
|
|
19
19
|
|
|
20
20
|
namespace quic
|
|
21
21
|
{
|
|
@@ -62,7 +62,7 @@ namespace quic
|
|
|
62
62
|
public:
|
|
63
63
|
struct WebTransportResponse
|
|
64
64
|
{
|
|
65
|
-
|
|
65
|
+
quiche::HttpHeaderBlock response_headers;
|
|
66
66
|
std::unique_ptr<WebTransportVisitor> visitor;
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -77,7 +77,7 @@ namespace quic
|
|
|
77
77
|
void setJSHandler(bool on) { jshandlerequesthandler_ = on; }
|
|
78
78
|
|
|
79
79
|
WebTransportRespPromisePtr ProcessWebTransportRequest(
|
|
80
|
-
const
|
|
80
|
+
const quiche::HttpHeaderBlock & /*request_headers*/,
|
|
81
81
|
WebTransportSession * /*session*/);
|
|
82
82
|
bool SupportsWebTransport() { return true; }
|
|
83
83
|
bool UsesDatagramContexts() { return true; }
|
|
@@ -33,7 +33,10 @@ namespace quic
|
|
|
33
33
|
QuicCompressedCertsCache *compressed_certs_cache,
|
|
34
34
|
Http3ServerBackend *http3_server_backend)
|
|
35
35
|
: QuicServerSessionBase(config, supported_versions, connection, visitor,
|
|
36
|
-
helper, crypto_config, compressed_certs_cache
|
|
36
|
+
helper, crypto_config, compressed_certs_cache,
|
|
37
|
+
http3_server_backend->SupportsWebTransport()
|
|
38
|
+
? QuicPriorityType::kWebTransport
|
|
39
|
+
: QuicPriorityType::kHttp),
|
|
37
40
|
http3_server_backend_(http3_server_backend)
|
|
38
41
|
{
|
|
39
42
|
QUICHE_DCHECK(http3_server_backend_);
|
package/src/http3serverstream.cc
CHANGED
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
#include "quiche/quic/platform/api/quic_flags.h"
|
|
26
26
|
#include "quiche/quic/platform/api/quic_logging.h"
|
|
27
27
|
#include "src/http3serversession.h"
|
|
28
|
-
#include "quiche/
|
|
28
|
+
#include "quiche/http2/core/spdy_protocol.h"
|
|
29
29
|
|
|
30
|
-
using
|
|
30
|
+
using quiche::HttpHeaderBlock;
|
|
31
31
|
|
|
32
32
|
namespace quic
|
|
33
33
|
{
|
|
@@ -279,7 +279,7 @@ namespace quic
|
|
|
279
279
|
std::string request_url = request_headers_[":authority"].as_string() +
|
|
280
280
|
request_headers_[":path"].as_string();
|
|
281
281
|
int response_code;
|
|
282
|
-
const
|
|
282
|
+
const HttpHeaderBlock &response_headers = response->headers();
|
|
283
283
|
if (!ParseHeaderStatusCode(response_headers, &response_code))
|
|
284
284
|
{
|
|
285
285
|
auto status = response_headers.find(":status");
|
|
@@ -317,7 +317,7 @@ namespace quic
|
|
|
317
317
|
SendNotFoundResponse();
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
HttpHeaderBlock headers = response->headers().Clone();
|
|
321
321
|
headers["content-length"] = absl::StrCat(generate_bytes_length_);
|
|
322
322
|
|
|
323
323
|
WriteHeaders(std::move(headers), false, nullptr);
|
|
@@ -356,7 +356,7 @@ namespace quic
|
|
|
356
356
|
void Http3ServerStream::SendNotFoundResponse()
|
|
357
357
|
{
|
|
358
358
|
QUIC_DVLOG(1) << "Stream " << id() << " sending not found response.";
|
|
359
|
-
|
|
359
|
+
HttpHeaderBlock headers;
|
|
360
360
|
headers[":status"] = "404";
|
|
361
361
|
headers["content-length"] = absl::StrCat(strlen(kNotFoundResponseBody));
|
|
362
362
|
SendHeadersAndBody(std::move(headers), kNotFoundResponseBody);
|
|
@@ -374,7 +374,7 @@ namespace quic
|
|
|
374
374
|
{
|
|
375
375
|
StopReading();
|
|
376
376
|
}
|
|
377
|
-
|
|
377
|
+
HttpHeaderBlock headers;
|
|
378
378
|
if (resp_code <= 0)
|
|
379
379
|
{
|
|
380
380
|
headers[":status"] = "500";
|
|
@@ -388,7 +388,7 @@ namespace quic
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
void Http3ServerStream::SendIncompleteResponse(
|
|
391
|
-
|
|
391
|
+
HttpHeaderBlock response_headers,
|
|
392
392
|
absl::string_view body)
|
|
393
393
|
{
|
|
394
394
|
QUIC_DLOG(INFO) << "Stream " << id() << " writing headers (fin = false) : "
|
|
@@ -406,17 +406,17 @@ namespace quic
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
void Http3ServerStream::SendHeadersAndBody(
|
|
409
|
-
|
|
409
|
+
HttpHeaderBlock response_headers,
|
|
410
410
|
absl::string_view body)
|
|
411
411
|
{
|
|
412
412
|
SendHeadersAndBodyAndTrailers(std::move(response_headers), body,
|
|
413
|
-
|
|
413
|
+
HttpHeaderBlock());
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
void Http3ServerStream::SendHeadersAndBodyAndTrailers(
|
|
417
|
-
|
|
417
|
+
HttpHeaderBlock response_headers,
|
|
418
418
|
absl::string_view body,
|
|
419
|
-
|
|
419
|
+
HttpHeaderBlock response_trailers)
|
|
420
420
|
{
|
|
421
421
|
// Send the headers, with a FIN if there's nothing else to send.
|
|
422
422
|
bool send_fin = (body.empty() && response_trailers.empty());
|
package/src/http3serverstream.h
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
#include "quiche/quic/core/quic_packets.h"
|
|
17
17
|
#include "src/http3serverbackend.h"
|
|
18
18
|
#include "src/http3backendresponse.h"
|
|
19
|
-
#include "quiche/
|
|
19
|
+
#include "quiche/http2/core/spdy_framer.h"
|
|
20
20
|
|
|
21
21
|
namespace quic
|
|
22
22
|
{
|
|
@@ -78,16 +78,16 @@ namespace quic
|
|
|
78
78
|
void SendNotFoundResponse();
|
|
79
79
|
|
|
80
80
|
// Sends the response header and body, but not the fin.
|
|
81
|
-
void SendIncompleteResponse(
|
|
81
|
+
void SendIncompleteResponse(quiche::HttpHeaderBlock response_headers,
|
|
82
82
|
absl::string_view body);
|
|
83
83
|
|
|
84
|
-
void SendHeadersAndBody(
|
|
84
|
+
void SendHeadersAndBody(quiche::HttpHeaderBlock response_headers,
|
|
85
85
|
absl::string_view body);
|
|
86
|
-
void SendHeadersAndBodyAndTrailers(
|
|
86
|
+
void SendHeadersAndBodyAndTrailers(quiche::HttpHeaderBlock response_headers,
|
|
87
87
|
absl::string_view body,
|
|
88
|
-
|
|
88
|
+
quiche::HttpHeaderBlock response_trailers);
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
quiche::HttpHeaderBlock *request_headers() { return &request_headers_; }
|
|
91
91
|
|
|
92
92
|
const std::string &body() { return body_; }
|
|
93
93
|
|
|
@@ -95,7 +95,7 @@ namespace quic
|
|
|
95
95
|
void WriteGeneratedBytes();
|
|
96
96
|
|
|
97
97
|
// The parsed headers received from the client.
|
|
98
|
-
|
|
98
|
+
quiche::HttpHeaderBlock request_headers_;
|
|
99
99
|
int64_t content_length_;
|
|
100
100
|
std::string body_;
|
|
101
101
|
// promises not fullfilled from js side or c++ side
|
|
@@ -45,7 +45,7 @@ namespace quic
|
|
|
45
45
|
<< stream->GetStreamId();
|
|
46
46
|
stream->SetVisitor(
|
|
47
47
|
std::make_unique<Http3WTStream::Visitor>(wtstream));
|
|
48
|
-
session_->getJS()->processStream(true, true, static_cast<Http3WTStream *>(wtstream));
|
|
48
|
+
session_->getJS()->processStream(true, true, 0/*sendOrder*/, 0 /*sendGroup*/, static_cast<Http3WTStream *>(wtstream));
|
|
49
49
|
stream->visitor()->OnCanRead();
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -67,7 +67,7 @@ namespace quic
|
|
|
67
67
|
<< "Http3WTSession received a unidirectional stream";
|
|
68
68
|
stream->SetVisitor(
|
|
69
69
|
std::make_unique<Http3WTStream::Visitor>(wtstream));
|
|
70
|
-
session_->getJS()->processStream(true, false, static_cast<Http3WTStream *>(wtstream));
|
|
70
|
+
session_->getJS()->processStream(true, false, 0/*sendOrder*/, 0 /*sendGroup*/, static_cast<Http3WTStream *>(wtstream));
|
|
71
71
|
stream->visitor()->OnCanRead();
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -104,22 +104,30 @@ namespace quic
|
|
|
104
104
|
getJS()->processDatagramStats(session_->GetDatagramStats());
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
size_t Http3WTSession::getMaxDatagramSizeInt()
|
|
108
|
+
{
|
|
109
|
+
if (!session_) return 0;
|
|
110
|
+
return session_->GetMaxDatagramSize();
|
|
111
|
+
}
|
|
112
|
+
|
|
107
113
|
void Http3WTSession::TrySendingBidirectionalStreams()
|
|
108
114
|
{
|
|
109
115
|
if (!session_)
|
|
110
116
|
return;
|
|
111
|
-
while (ordBidiStreams
|
|
117
|
+
while (!ordBidiStreams.empty() &&
|
|
112
118
|
session_->CanOpenNextOutgoingBidirectionalStream())
|
|
113
119
|
{
|
|
114
120
|
QUIC_DVLOG(1)
|
|
115
121
|
<< "Http3WTSessionVisitor opens a bidirectional stream";
|
|
116
122
|
WebTransportStream *stream = session_->OpenOutgoingBidirectionalStream();
|
|
123
|
+
webtransport::StreamPriority prio = ordBidiStreams.front();
|
|
124
|
+
stream->SetPriority(prio);
|
|
117
125
|
Http3WTStream *wtstream = new Http3WTStream(stream);
|
|
118
126
|
stream->SetVisitor(
|
|
119
127
|
std::make_unique<Http3WTStream::Visitor>(wtstream));
|
|
120
|
-
getJS()->processStream(false, true, static_cast<Http3WTStream *>(wtstream));
|
|
128
|
+
getJS()->processStream(false, true, prio.send_order, prio.send_group_id, static_cast<Http3WTStream *>(wtstream));
|
|
121
129
|
stream->visitor()->OnCanWrite();
|
|
122
|
-
ordBidiStreams
|
|
130
|
+
ordBidiStreams.pop();
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
|
|
@@ -127,7 +135,7 @@ namespace quic
|
|
|
127
135
|
{
|
|
128
136
|
if (!session_->session_) return;
|
|
129
137
|
|
|
130
|
-
session_->getJS()->processSessionReady();
|
|
138
|
+
session_->getJS()->processSessionReady(session_->session_->GetNegotiatedSubprotocol());
|
|
131
139
|
|
|
132
140
|
if (session_->session_->CanOpenNextOutgoingBidirectionalStream())
|
|
133
141
|
{
|
|
@@ -144,37 +152,43 @@ namespace quic
|
|
|
144
152
|
if (!session_)
|
|
145
153
|
return;
|
|
146
154
|
// move to some where else?
|
|
147
|
-
while (ordUnidiStreams
|
|
155
|
+
while (!ordUnidiStreams.empty() &&
|
|
148
156
|
session_->CanOpenNextOutgoingUnidirectionalStream())
|
|
149
157
|
{
|
|
150
158
|
QUIC_DVLOG(1)
|
|
151
159
|
<< "Http3WTSessionVisitor opened a unidirectional stream";
|
|
152
160
|
WebTransportStream *stream = session_->OpenOutgoingUnidirectionalStream();
|
|
161
|
+
webtransport::StreamPriority prio = ordUnidiStreams.front();
|
|
162
|
+
stream->SetPriority(prio);
|
|
153
163
|
Http3WTStream *wtstream = new Http3WTStream(stream);
|
|
154
164
|
stream->SetVisitor(
|
|
155
165
|
std::make_unique<Http3WTStream::Visitor>(wtstream));
|
|
156
166
|
|
|
157
|
-
getJS()->processStream(false, false, static_cast<Http3WTStream *>(wtstream));
|
|
167
|
+
getJS()->processStream(false, false, prio.send_order, prio.send_group_id, static_cast<Http3WTStream *>(wtstream));
|
|
158
168
|
stream->visitor()->OnCanWrite();
|
|
159
|
-
ordUnidiStreams
|
|
169
|
+
ordUnidiStreams.pop();
|
|
160
170
|
}
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
|
|
173
|
+
webtransport::DatagramStatus Http3WTSession::writeDatagramInt(char *buffer, size_t len, Napi::ObjectReference *bufferhandle)
|
|
164
174
|
{
|
|
165
175
|
// printf("Datagram write %d %x %x\n", getpid(), this, session_ );
|
|
166
176
|
if (!session_)
|
|
167
177
|
{
|
|
168
178
|
// printf("Datagram session gone %d %x %x\n", getpid(), this, session_);
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
bufferhandle->Unref(); // release the outgoing buffer
|
|
180
|
+
delete bufferhandle; // free the handle object
|
|
181
|
+
webtransport::DatagramStatus status(webtransport::DatagramStatusCode::kInternalError, "Session not present");
|
|
182
|
+
return status;
|
|
171
183
|
}
|
|
172
|
-
|
|
184
|
+
webtransport::DatagramStatus status = session_->SendOrQueueDatagram(absl::string_view(buffer, len));
|
|
173
185
|
// printf("Datagram status %d %d %s %x %x\n", getpid(), status.code, status.error_message.c_str(), this, session_);
|
|
174
|
-
|
|
186
|
+
bufferhandle->Unref(); // release the outgoing buffer
|
|
187
|
+
delete bufferhandle; // free the handle object
|
|
188
|
+
return status;
|
|
175
189
|
}
|
|
176
190
|
|
|
177
|
-
void Http3WTSessionJS::processStream(bool incom, bool bidi, Http3WTStream *stream)
|
|
191
|
+
void Http3WTSessionJS::processStream(bool incom, bool bidi, uint64_t sendOrder, uint64_t sendGroupId, Http3WTStream *stream)
|
|
178
192
|
{
|
|
179
193
|
Napi::HandleScope scope(Env());
|
|
180
194
|
Http3Constructors *constr = Env().GetInstanceData<Http3Constructors>();
|
|
@@ -192,6 +206,8 @@ namespace quic
|
|
|
192
206
|
retObj.Set("stream", strobj);
|
|
193
207
|
retObj.Set("incoming", incom);
|
|
194
208
|
retObj.Set("bidirectional", bidi);
|
|
209
|
+
retObj.Set("sendOrder", sendOrder);
|
|
210
|
+
retObj.Set("sendGroupId", sendGroupId);
|
|
195
211
|
|
|
196
212
|
objVal.Get("onStream").As<Napi::Function>().Call(objVal, {retObj});
|
|
197
213
|
}
|
|
@@ -263,13 +279,16 @@ namespace quic
|
|
|
263
279
|
objVal.Get("onDatagramSend").As<Napi::Function>().Call(objVal, {retObj});
|
|
264
280
|
}
|
|
265
281
|
|
|
266
|
-
void Http3WTSessionJS::processSessionReady()
|
|
282
|
+
void Http3WTSessionJS::processSessionReady(std::optional<std::string> protocol)
|
|
267
283
|
{
|
|
268
284
|
Napi::HandleScope scope(Env());
|
|
269
285
|
Napi::Object objVal = Value().Get("jsobj").As<Napi::Object>();
|
|
270
286
|
|
|
271
287
|
Napi::Object retObj = Napi::Object::New(Env());
|
|
272
288
|
|
|
289
|
+
if (protocol.has_value()) {
|
|
290
|
+
retObj.Set("protocol", protocol.value());
|
|
291
|
+
}
|
|
273
292
|
objVal.Get("onReady").As<Napi::Function>().Call(objVal, {retObj});
|
|
274
293
|
}
|
|
275
294
|
|