@fails-components/webtransport 0.0.5 → 0.0.6
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 +0 -2
- package/package.json +2 -1
- package/src/http3client.cc +57 -36
- package/src/http3client.h +20 -20
- package/src/http3serverbackend.h +1 -1
- package/src/http3wtsessionvisitor.cc +1 -1
- package/src/http3wtsessionvisitor.h +1 -1
- package/src/webtransport.js +1 -0
- package/platform/quiche_platform_impl/quic_flags_impl.h +0 -9
package/CMakeLists.txt
CHANGED
|
@@ -240,8 +240,6 @@ third_party/quiche/quiche/common/platform/api/quiche_reference_counted.h
|
|
|
240
240
|
third_party/quiche/quiche/common/platform/api/quiche_thread_local.h
|
|
241
241
|
third_party/quiche/quiche/common/platform/api/quiche_time_utils.h
|
|
242
242
|
third_party/quiche/quiche/common/platform/api/quiche_url_utils.h
|
|
243
|
-
third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quic_flags_impl.cc
|
|
244
|
-
third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quic_flags_impl.h
|
|
245
243
|
third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_flag_utils_impl.h
|
|
246
244
|
third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_flags_impl.h
|
|
247
245
|
third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_flags_impl.cc
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fails-components/webtransport",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A component to add webtransport support (server and client) to node.js using libquiche",
|
|
5
5
|
"main": "src/webtransport.js",
|
|
6
6
|
"module": "src/webtransport.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"start": "node test/echoserver.js",
|
|
13
13
|
"test": "node test/test.js",
|
|
14
14
|
"install": "node build.js install",
|
|
15
|
+
"build": "node build.js build",
|
|
15
16
|
"rebuild": "node build.js rebuild",
|
|
16
17
|
"rebuild-debug": "node build.js rebuild-debug -D",
|
|
17
18
|
"build-debug": "node build.js build-debug"
|
package/src/http3client.cc
CHANGED
|
@@ -44,6 +44,42 @@ using spdy::Http2HeaderBlock;
|
|
|
44
44
|
namespace quic
|
|
45
45
|
{
|
|
46
46
|
|
|
47
|
+
// taken from libquiche
|
|
48
|
+
namespace
|
|
49
|
+
{
|
|
50
|
+
|
|
51
|
+
// For level-triggered I/O, we need to manually rearm the kSocketEventWritable
|
|
52
|
+
// listener whenever the socket gets blocked.
|
|
53
|
+
class LevelTriggeredPacketWriter : public QuicDefaultPacketWriter
|
|
54
|
+
{
|
|
55
|
+
public:
|
|
56
|
+
explicit LevelTriggeredPacketWriter(int fd, QuicEventLoop *event_loop)
|
|
57
|
+
: QuicDefaultPacketWriter(fd), event_loop_(event_loop)
|
|
58
|
+
{
|
|
59
|
+
QUICHE_DCHECK(!event_loop->SupportsEdgeTriggered());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
WriteResult WritePacket(const char *buffer, size_t buf_len,
|
|
63
|
+
const QuicIpAddress &self_address,
|
|
64
|
+
const QuicSocketAddress &peer_address,
|
|
65
|
+
PerPacketOptions *options) override
|
|
66
|
+
{
|
|
67
|
+
WriteResult result = QuicDefaultPacketWriter::WritePacket(
|
|
68
|
+
buffer, buf_len, self_address, peer_address, options);
|
|
69
|
+
if (IsWriteBlockedStatus(result.status))
|
|
70
|
+
{
|
|
71
|
+
bool success = event_loop_->RearmSocket(fd(), kSocketEventWritable);
|
|
72
|
+
QUICHE_DCHECK(success);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
QuicEventLoop *event_loop_;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace
|
|
82
|
+
|
|
47
83
|
// taken from chromium to behave like the browser
|
|
48
84
|
// A version of WebTransportFingerprintProofVerifier that enforces
|
|
49
85
|
// Chromium-specific policies.
|
|
@@ -168,7 +204,7 @@ namespace quic
|
|
|
168
204
|
|
|
169
205
|
void Http3Client::SendRequest(const std::string &uri)
|
|
170
206
|
{
|
|
171
|
-
spdy::
|
|
207
|
+
spdy::Http2HeaderBlock headers;
|
|
172
208
|
if (!PopulateHeaderBlockFromUrl(uri, &headers))
|
|
173
209
|
{
|
|
174
210
|
return;
|
|
@@ -178,7 +214,7 @@ namespace quic
|
|
|
178
214
|
|
|
179
215
|
void Http3Client::SendRequestAndRstTogether(const std::string &uri)
|
|
180
216
|
{
|
|
181
|
-
spdy::
|
|
217
|
+
spdy::Http2HeaderBlock headers;
|
|
182
218
|
if (!PopulateHeaderBlockFromUrl(uri, &headers))
|
|
183
219
|
{
|
|
184
220
|
return;
|
|
@@ -194,7 +230,7 @@ namespace quic
|
|
|
194
230
|
}
|
|
195
231
|
|
|
196
232
|
void Http3Client::GetOrCreateStreamAndSendRequest(
|
|
197
|
-
const spdy::
|
|
233
|
+
const spdy::Http2HeaderBlock *headers, absl::string_view body, bool fin)
|
|
198
234
|
{
|
|
199
235
|
if (headers)
|
|
200
236
|
{
|
|
@@ -206,8 +242,8 @@ namespace quic
|
|
|
206
242
|
if (rv == QUIC_PENDING)
|
|
207
243
|
{
|
|
208
244
|
// May need to retry request if asynchronous rendezvous fails.
|
|
209
|
-
std::unique_ptr<spdy::
|
|
210
|
-
new spdy::
|
|
245
|
+
std::unique_ptr<spdy::Http2HeaderBlock> new_headers(
|
|
246
|
+
new spdy::Http2HeaderBlock(headers->Clone()));
|
|
211
247
|
push_promise_data_to_resend_ = std::make_unique<Http3ClientDataToResend>(
|
|
212
248
|
std::move(new_headers), body, fin, this);
|
|
213
249
|
return;
|
|
@@ -218,7 +254,7 @@ namespace quic
|
|
|
218
254
|
bool hasheaders = false;
|
|
219
255
|
if (headers != nullptr)
|
|
220
256
|
{
|
|
221
|
-
spdy_headers = std::make_shared<spdy::
|
|
257
|
+
spdy_headers = std::make_shared<spdy::Http2HeaderBlock>(headers->Clone());
|
|
222
258
|
hasheaders = true;
|
|
223
259
|
}
|
|
224
260
|
|
|
@@ -252,13 +288,13 @@ namespace quic
|
|
|
252
288
|
});
|
|
253
289
|
}
|
|
254
290
|
|
|
255
|
-
void Http3Client::SendMessageAsync(const spdy::
|
|
291
|
+
void Http3Client::SendMessageAsync(const spdy::Http2HeaderBlock &headers,
|
|
256
292
|
absl::string_view body)
|
|
257
293
|
{
|
|
258
294
|
return SendMessageAsync(headers, body, /*fin=*/true);
|
|
259
295
|
}
|
|
260
296
|
|
|
261
|
-
void Http3Client::SendMessageAsync(const spdy::
|
|
297
|
+
void Http3Client::SendMessageAsync(const spdy::Http2HeaderBlock &headers,
|
|
262
298
|
absl::string_view body, bool fin)
|
|
263
299
|
{
|
|
264
300
|
// Always force creation of a stream for SendMessage.
|
|
@@ -667,7 +703,7 @@ namespace quic
|
|
|
667
703
|
|
|
668
704
|
void Http3Client::openWTSessionInt(absl::string_view path)
|
|
669
705
|
{
|
|
670
|
-
spdy::
|
|
706
|
+
spdy::Http2HeaderBlock headers;
|
|
671
707
|
headers[":scheme"] = "https";
|
|
672
708
|
headers[":authority"] = "localhost";
|
|
673
709
|
headers[":path"] = path;
|
|
@@ -691,7 +727,7 @@ namespace quic
|
|
|
691
727
|
{
|
|
692
728
|
QUICHE_DCHECK(initialized_);
|
|
693
729
|
QUICHE_DCHECK(!connected());
|
|
694
|
-
QuicPacketWriter *writer = new
|
|
730
|
+
QuicPacketWriter *writer = new LevelTriggeredPacketWriter(GetLatestFD(), eventloop_->getQuicEventLoop());
|
|
695
731
|
ParsedQuicVersion mutual_version = UnsupportedQuicVersion();
|
|
696
732
|
const bool can_reconnect_with_different_version =
|
|
697
733
|
CanReconnectWithDifferentVersion(&mutual_version);
|
|
@@ -895,15 +931,10 @@ namespace quic
|
|
|
895
931
|
QUICHE_DCHECK(success);
|
|
896
932
|
}
|
|
897
933
|
}
|
|
898
|
-
bool writeblocked = false;
|
|
899
934
|
if (connected() && (events & kSocketEventWritable))
|
|
900
935
|
{
|
|
901
936
|
writer_->SetWritable();
|
|
902
937
|
session_->connection()->OnCanWrite();
|
|
903
|
-
if (writer_->IsWriteBlocked())
|
|
904
|
-
{
|
|
905
|
-
writeblocked = true;
|
|
906
|
-
}
|
|
907
938
|
}
|
|
908
939
|
|
|
909
940
|
if (handleConnecting())
|
|
@@ -912,16 +943,6 @@ namespace quic
|
|
|
912
943
|
event_loop->ArtificiallyNotifyEvent(fd, kSocketEventReadable);
|
|
913
944
|
QUICHE_DCHECK(success);
|
|
914
945
|
}
|
|
915
|
-
if (writer_->IsWriteBlocked())
|
|
916
|
-
{
|
|
917
|
-
writeblocked = true;
|
|
918
|
-
}
|
|
919
|
-
if (!event_loop->SupportsEdgeTriggered() && writeblocked)
|
|
920
|
-
{
|
|
921
|
-
bool success = event_loop->RearmSocket(fd, kSocketEventWritable);
|
|
922
|
-
QUICHE_DCHECK(success);
|
|
923
|
-
|
|
924
|
-
}
|
|
925
946
|
}
|
|
926
947
|
|
|
927
948
|
void Http3Client::ProcessPacket(
|
|
@@ -943,7 +964,7 @@ namespace quic
|
|
|
943
964
|
return response_headers_complete_;
|
|
944
965
|
}
|
|
945
966
|
|
|
946
|
-
const spdy::
|
|
967
|
+
const spdy::Http2HeaderBlock *Http3Client::response_headers() const
|
|
947
968
|
{
|
|
948
969
|
for (std::pair<QuicStreamId, QuicSpdyClientStream *> stream : open_streams_)
|
|
949
970
|
{
|
|
@@ -956,7 +977,7 @@ namespace quic
|
|
|
956
977
|
return &response_headers_;
|
|
957
978
|
}
|
|
958
979
|
|
|
959
|
-
const spdy::
|
|
980
|
+
const spdy::Http2HeaderBlock *Http3Client::preliminary_headers() const
|
|
960
981
|
{
|
|
961
982
|
for (std::pair<QuicStreamId, QuicSpdyClientStream *> stream : open_streams_)
|
|
962
983
|
{
|
|
@@ -971,7 +992,7 @@ namespace quic
|
|
|
971
992
|
return &preliminary_headers_;
|
|
972
993
|
}
|
|
973
994
|
|
|
974
|
-
const spdy::
|
|
995
|
+
const spdy::Http2HeaderBlock &Http3Client::response_trailers() const
|
|
975
996
|
{
|
|
976
997
|
return response_trailers_;
|
|
977
998
|
}
|
|
@@ -1080,9 +1101,9 @@ namespace quic
|
|
|
1080
1101
|
}
|
|
1081
1102
|
|
|
1082
1103
|
bool Http3Client::CheckVary(
|
|
1083
|
-
const spdy::
|
|
1084
|
-
const spdy::
|
|
1085
|
-
const spdy::
|
|
1104
|
+
const spdy::Http2HeaderBlock & /*client_request*/,
|
|
1105
|
+
const spdy::Http2HeaderBlock & /*promise_request*/,
|
|
1106
|
+
const spdy::Http2HeaderBlock & /*promise_response*/)
|
|
1086
1107
|
{
|
|
1087
1108
|
return true;
|
|
1088
1109
|
}
|
|
@@ -1174,7 +1195,7 @@ namespace quic
|
|
|
1174
1195
|
}
|
|
1175
1196
|
|
|
1176
1197
|
Http3Client::Http3ClientDataToResend::Http3ClientDataToResend(
|
|
1177
|
-
std::unique_ptr<spdy::
|
|
1198
|
+
std::unique_ptr<spdy::Http2HeaderBlock> headers, absl::string_view body,
|
|
1178
1199
|
bool fin, Http3Client *client)
|
|
1179
1200
|
: headers_(std::move(headers)), body_(body), fin_(fin),
|
|
1180
1201
|
client_(client) {}
|
|
@@ -1202,9 +1223,9 @@ namespace quic
|
|
|
1202
1223
|
Http3Client::PerStreamState::PerStreamState(
|
|
1203
1224
|
QuicRstStreamErrorCode stream_error, bool response_complete,
|
|
1204
1225
|
bool response_headers_complete,
|
|
1205
|
-
const spdy::
|
|
1206
|
-
const spdy::
|
|
1207
|
-
const std::string &response, const spdy::
|
|
1226
|
+
const spdy::Http2HeaderBlock &response_headers,
|
|
1227
|
+
const spdy::Http2HeaderBlock &preliminary_headers,
|
|
1228
|
+
const std::string &response, const spdy::Http2HeaderBlock &response_trailers,
|
|
1208
1229
|
uint64_t bytes_read, uint64_t bytes_written, int64_t response_body_size)
|
|
1209
1230
|
: stream_error(stream_error),
|
|
1210
1231
|
response_complete(response_complete),
|
|
@@ -1220,7 +1241,7 @@ namespace quic
|
|
|
1220
1241
|
Http3Client::PerStreamState::~PerStreamState() = default;
|
|
1221
1242
|
|
|
1222
1243
|
bool Http3Client::PopulateHeaderBlockFromUrl(
|
|
1223
|
-
const std::string &uri, spdy::
|
|
1244
|
+
const std::string &uri, spdy::Http2HeaderBlock *headers)
|
|
1224
1245
|
{
|
|
1225
1246
|
std::string url;
|
|
1226
1247
|
if (absl::StartsWith(uri, "https://") || absl::StartsWith(uri, "http://"))
|
package/src/http3client.h
CHANGED
|
@@ -133,12 +133,12 @@ namespace quic
|
|
|
133
133
|
|
|
134
134
|
// Sends a request containing |headers| and |body| and returns the number of
|
|
135
135
|
// bytes sent (the size of the serialized request headers and body).
|
|
136
|
-
void SendMessageAsync(const spdy::
|
|
136
|
+
void SendMessageAsync(const spdy::Http2HeaderBlock &headers,
|
|
137
137
|
absl::string_view body);
|
|
138
138
|
// Sends a request containing |headers| and |body| with the fin bit set to
|
|
139
139
|
// |fin| and returns the number of bytes sent (the size of the serialized
|
|
140
140
|
// request headers and body).
|
|
141
|
-
void SendMessageAsync(const spdy::
|
|
141
|
+
void SendMessageAsync(const spdy::Http2HeaderBlock &headers,
|
|
142
142
|
absl::string_view body, bool fin);
|
|
143
143
|
|
|
144
144
|
void SendConnectivityProbing();
|
|
@@ -173,14 +173,14 @@ namespace quic
|
|
|
173
173
|
// is received. 2) returns state of the oldest active stream which have
|
|
174
174
|
// received partial response (if any).
|
|
175
175
|
// Group 1.
|
|
176
|
-
const spdy::
|
|
176
|
+
const spdy::Http2HeaderBlock &response_trailers() const;
|
|
177
177
|
bool response_complete() const;
|
|
178
178
|
int64_t response_body_size() const;
|
|
179
179
|
const std::string &response_body() const;
|
|
180
180
|
// Group 2.
|
|
181
181
|
bool response_headers_complete() const;
|
|
182
|
-
const spdy::
|
|
183
|
-
const spdy::
|
|
182
|
+
const spdy::Http2HeaderBlock *response_headers() const;
|
|
183
|
+
const spdy::Http2HeaderBlock *preliminary_headers() const;
|
|
184
184
|
int64_t response_size() const;
|
|
185
185
|
size_t bytes_read() const;
|
|
186
186
|
size_t bytes_written() const;
|
|
@@ -221,9 +221,9 @@ namespace quic
|
|
|
221
221
|
const std::string &response_body);
|
|
222
222
|
|
|
223
223
|
// From QuicClientPushPromiseIndex::Delegate
|
|
224
|
-
bool CheckVary(const spdy::
|
|
225
|
-
const spdy::
|
|
226
|
-
const spdy::
|
|
224
|
+
bool CheckVary(const spdy::Http2HeaderBlock &client_request,
|
|
225
|
+
const spdy::Http2HeaderBlock &promise_request,
|
|
226
|
+
const spdy::Http2HeaderBlock &promise_response) override;
|
|
227
227
|
void OnRendezvousResult(QuicSpdyStream *) override;
|
|
228
228
|
|
|
229
229
|
// Returns nullptr if the maximum number of streams have already been created.
|
|
@@ -235,7 +235,7 @@ namespace quic
|
|
|
235
235
|
// stores the request in case it needs to be resent. If |headers| is
|
|
236
236
|
// null, only the body will be sent on the stream.
|
|
237
237
|
void GetOrCreateStreamAndSendRequest(
|
|
238
|
-
const spdy::
|
|
238
|
+
const spdy::Http2HeaderBlock *headers, absl::string_view body, bool fin);
|
|
239
239
|
|
|
240
240
|
QuicRstStreamErrorCode stream_error() { return stream_error_; }
|
|
241
241
|
QuicErrorCode connection_error() const;
|
|
@@ -272,7 +272,7 @@ namespace quic
|
|
|
272
272
|
// request. If |uri| is a relative URL, the QuicServerId will be
|
|
273
273
|
// use to specify the authority.
|
|
274
274
|
bool PopulateHeaderBlockFromUrl(const std::string &uri,
|
|
275
|
-
spdy::
|
|
275
|
+
spdy::Http2HeaderBlock *headers);
|
|
276
276
|
|
|
277
277
|
QuicSpdyClientStream *latest_created_stream()
|
|
278
278
|
{
|
|
@@ -300,7 +300,7 @@ namespace quic
|
|
|
300
300
|
{
|
|
301
301
|
public:
|
|
302
302
|
Http3ClientDataToResend(
|
|
303
|
-
std::unique_ptr<spdy::
|
|
303
|
+
std::unique_ptr<spdy::Http2HeaderBlock> headers, absl::string_view body,
|
|
304
304
|
bool fin, Http3Client *client);
|
|
305
305
|
|
|
306
306
|
~Http3ClientDataToResend();
|
|
@@ -320,10 +320,10 @@ namespace quic
|
|
|
320
320
|
PerStreamState(const PerStreamState &other);
|
|
321
321
|
PerStreamState(QuicRstStreamErrorCode stream_error, bool response_complete,
|
|
322
322
|
bool response_headers_complete,
|
|
323
|
-
const spdy::
|
|
324
|
-
const spdy::
|
|
323
|
+
const spdy::Http2HeaderBlock &response_headers,
|
|
324
|
+
const spdy::Http2HeaderBlock &preliminary_headers,
|
|
325
325
|
const std::string &response,
|
|
326
|
-
const spdy::
|
|
326
|
+
const spdy::Http2HeaderBlock &response_trailers,
|
|
327
327
|
uint64_t bytes_read, uint64_t bytes_written,
|
|
328
328
|
int64_t response_body_size);
|
|
329
329
|
~PerStreamState();
|
|
@@ -331,10 +331,10 @@ namespace quic
|
|
|
331
331
|
QuicRstStreamErrorCode stream_error;
|
|
332
332
|
bool response_complete;
|
|
333
333
|
bool response_headers_complete;
|
|
334
|
-
spdy::
|
|
335
|
-
spdy::
|
|
334
|
+
spdy::Http2HeaderBlock response_headers;
|
|
335
|
+
spdy::Http2HeaderBlock preliminary_headers;
|
|
336
336
|
std::string response;
|
|
337
|
-
spdy::
|
|
337
|
+
spdy::Http2HeaderBlock response_trailers;
|
|
338
338
|
uint64_t bytes_read;
|
|
339
339
|
uint64_t bytes_written;
|
|
340
340
|
int64_t response_body_size;
|
|
@@ -396,11 +396,11 @@ namespace quic
|
|
|
396
396
|
|
|
397
397
|
bool response_complete_;
|
|
398
398
|
bool response_headers_complete_;
|
|
399
|
-
mutable spdy::
|
|
400
|
-
mutable spdy::
|
|
399
|
+
mutable spdy::Http2HeaderBlock preliminary_headers_;
|
|
400
|
+
mutable spdy::Http2HeaderBlock response_headers_;
|
|
401
401
|
|
|
402
402
|
// Parsed response trailers (if present), copied from the stream in OnClose.
|
|
403
|
-
spdy::
|
|
403
|
+
spdy::Http2HeaderBlock response_trailers_;
|
|
404
404
|
|
|
405
405
|
spdy::SpdyPriority priority_;
|
|
406
406
|
std::string response_;
|
package/src/http3serverbackend.h
CHANGED
|
@@ -25,7 +25,7 @@ namespace quic
|
|
|
25
25
|
session_->eventloop_->informSessionClosed(session_, error_code, error_message);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
void Http3WTSession::Visitor::OnSessionReady(const spdy::
|
|
28
|
+
void Http3WTSession::Visitor::OnSessionReady(const spdy::Http2HeaderBlock &)
|
|
29
29
|
{
|
|
30
30
|
session_->eventloop_->informSessionReady(session_);
|
|
31
31
|
|
|
@@ -62,7 +62,7 @@ namespace quic
|
|
|
62
62
|
|
|
63
63
|
~Visitor();
|
|
64
64
|
|
|
65
|
-
void OnSessionReady(const spdy::
|
|
65
|
+
void OnSessionReady(const spdy::Http2HeaderBlock &) override;
|
|
66
66
|
|
|
67
67
|
void OnSessionClosed(WebTransportSessionError error_code,
|
|
68
68
|
const std::string &error_message) override;
|
package/src/webtransport.js
CHANGED