@fails-components/webtransport 0.3.1 → 1.0.1
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/lib/client.js +81 -40
- package/lib/dom.ts +7 -5
- package/lib/http2/browser/browser.js +168 -0
- package/lib/http2/browser/browserparser.js +248 -0
- package/lib/http2/flowcontroller.js +371 -0
- package/lib/http2/node/capsuleparser.js +291 -0
- package/lib/http2/node/client.js +239 -0
- package/lib/http2/node/index.js +2 -0
- package/lib/http2/node/server.js +499 -0
- package/lib/http2/node/websocketparser.js +829 -0
- package/lib/http2/parserbase.js +139 -0
- package/lib/http2/parserbasehttp2.js +128 -0
- package/lib/http2/session.js +225 -0
- package/lib/http2/stream.js +354 -0
- package/lib/http2/websocketcommon.js +1 -0
- package/lib/{index.js → index.browser.js} +6 -10
- package/lib/index.node.js +27 -0
- package/lib/server.js +252 -69
- package/lib/session.js +31 -68
- package/lib/stream.js +103 -179
- package/lib/types.ts +174 -87
- package/lib/utils.js +2 -1
- package/lib/webstreams.browser.js +6 -0
- package/lib/webstreams.js +7 -0
- package/lib/webtransport.browser.js +284 -0
- package/lib/webtransport.node.js +137 -0
- package/lib/{webtransport.js → webtransportbase.js} +47 -41
- package/old_test/test.js +31 -29
- package/old_test/testsuite.js +1 -1
- package/package.json +18 -17
- package/readme.md +94 -30
- package/test/bidirectional-streams.spec.js +51 -9
- package/test/datagrams.spec.js +8 -2
- package/test/fixtures/known-bytes.js +29 -0
- package/test/fixtures/read-stream.js +1 -1
- package/test/fixtures/reader-value.js +1 -1
- package/test/fixtures/server.js +24 -10
- package/test/fixtures/webtransport.browser.js +20 -2
- package/test/fixtures/webtransport.js +1 -1
- package/test/index.js +33 -6
- package/test/pw-no-https-errors.json +5 -0
- package/test/session.spec.js +71 -52
- package/test/unidirectional-streams.spec.js +20 -4
- package/CMakeLists.txt +0 -991
- package/LICENSE.chromium +0 -27
- package/LICENSE.envoy +0 -207
- package/build.js +0 -313
- package/dist/lib/client.d.ts +0 -78
- package/dist/lib/client.d.ts.map +0 -1
- package/dist/lib/dom.d.ts +0 -87
- package/dist/lib/dom.d.ts.map +0 -1
- package/dist/lib/error.d.ts +0 -8
- package/dist/lib/error.d.ts.map +0 -1
- package/dist/lib/event-loop.d.ts +0 -33
- package/dist/lib/event-loop.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -79
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/native.d.ts +0 -2
- package/dist/lib/native.d.ts.map +0 -1
- package/dist/lib/server.d.ts +0 -92
- package/dist/lib/server.d.ts.map +0 -1
- package/dist/lib/session.d.ts +0 -298
- package/dist/lib/session.d.ts.map +0 -1
- package/dist/lib/stream.d.ts +0 -135
- package/dist/lib/stream.d.ts.map +0 -1
- package/dist/lib/transport.d.ts +0 -34
- package/dist/lib/transport.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -212
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -11
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/webtransport.d.ts +0 -47
- package/dist/lib/webtransport.d.ts.map +0 -1
- package/dist/test/bidirectional-streams.spec.d.ts +0 -5
- package/dist/test/bidirectional-streams.spec.d.ts.map +0 -1
- package/dist/test/datagrams.spec.d.ts +0 -5
- package/dist/test/datagrams.spec.d.ts.map +0 -1
- package/dist/test/event-loop.node.d.ts +0 -2
- package/dist/test/event-loop.node.d.ts.map +0 -1
- package/dist/test/fixtures/certificate.d.ts +0 -21
- package/dist/test/fixtures/certificate.d.ts.map +0 -1
- package/dist/test/fixtures/chai.d.ts +0 -2
- package/dist/test/fixtures/chai.d.ts.map +0 -1
- package/dist/test/fixtures/known-bytes.d.ts +0 -6
- package/dist/test/fixtures/known-bytes.d.ts.map +0 -1
- package/dist/test/fixtures/p-timeout.d.ts +0 -8
- package/dist/test/fixtures/p-timeout.d.ts.map +0 -1
- package/dist/test/fixtures/read-cert-hash.d.ts +0 -6
- package/dist/test/fixtures/read-cert-hash.d.ts.map +0 -1
- package/dist/test/fixtures/read-stream.d.ts +0 -19
- package/dist/test/fixtures/read-stream.d.ts.map +0 -1
- package/dist/test/fixtures/reader-value.d.ts +0 -22
- package/dist/test/fixtures/reader-value.d.ts.map +0 -1
- package/dist/test/fixtures/server.d.ts +0 -5
- package/dist/test/fixtures/server.d.ts.map +0 -1
- package/dist/test/fixtures/webtransport.browser.d.ts +0 -3
- package/dist/test/fixtures/webtransport.browser.d.ts.map +0 -1
- package/dist/test/fixtures/webtransport.d.ts +0 -3
- package/dist/test/fixtures/webtransport.d.ts.map +0 -1
- package/dist/test/fixtures/write-stream.d.ts +0 -10
- package/dist/test/fixtures/write-stream.d.ts.map +0 -1
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.d.ts.map +0 -1
- package/dist/test/session.spec.d.ts +0 -5
- package/dist/test/session.spec.d.ts.map +0 -1
- package/dist/test/unidirectional-streams.spec.d.ts +0 -2
- package/dist/test/unidirectional-streams.spec.d.ts.map +0 -1
- package/failslogolicensereadme.txt +0 -4
- package/lib/event-loop.js +0 -88
- package/lib/native.js +0 -28
- package/lib/transport.js +0 -82
- package/platform/icufix/fakedata.cpp +0 -8
- package/platform/quiche/quic/core/io/socket_win.inc +0 -3
- package/platform/quiche_platform_impl/quiche_bug_tracker_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_client_stats_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_containers_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_event_loop_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_export_impl.h +0 -6
- package/platform/quiche_platform_impl/quiche_flag_utils_impl.h +0 -11
- package/platform/quiche_platform_impl/quiche_flags_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_iovec_impl.h +0 -10
- package/platform/quiche_platform_impl/quiche_logging_impl.h +0 -21
- package/platform/quiche_platform_impl/quiche_mem_slice_impl.h +0 -2
- package/platform/quiche_platform_impl/quiche_mutex_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_prefetch_impl.h +0 -11
- package/platform/quiche_platform_impl/quiche_reference_counted_impl.h +0 -16
- package/platform/quiche_platform_impl/quiche_server_stats_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_stack_trace_impl.h +0 -12
- package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_testvalue_impl.h +0 -1
- package/platform/quiche_platform_impl/quiche_thread_local_impl.h +0 -6
- package/platform/quiche_platform_impl/quiche_time_utils_impl.h +0 -13
- package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +0 -39
- package/src/http3backendresponse.cc +0 -36
- package/src/http3backendresponse.h +0 -109
- package/src/http3client.cc +0 -1529
- package/src/http3client.h +0 -557
- package/src/http3clientsession.cc +0 -65
- package/src/http3clientsession.h +0 -60
- package/src/http3clientstream.cc +0 -52
- package/src/http3clientstream.h +0 -42
- package/src/http3dispatcher.cc +0 -62
- package/src/http3dispatcher.h +0 -57
- package/src/http3eventloop.cc +0 -1107
- package/src/http3eventloop.h +0 -316
- package/src/http3server.cc +0 -514
- package/src/http3server.h +0 -151
- package/src/http3serverbackend.cc +0 -105
- package/src/http3serverbackend.h +0 -98
- package/src/http3serversession.cc +0 -123
- package/src/http3serversession.h +0 -95
- package/src/http3serverstream.cc +0 -463
- package/src/http3serverstream.h +0 -114
- package/src/http3sessioncache.cc +0 -85
- package/src/http3sessioncache.h +0 -59
- package/src/http3wtsessionvisitor.cc +0 -46
- package/src/http3wtsessionvisitor.h +0 -397
- package/src/http3wtstreamvisitor.cc +0 -155
- package/src/http3wtstreamvisitor.h +0 -404
- package/test/event-loop.node.js +0 -24
- package/tsconfig.json +0 -39
package/lib/stream.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ReadableStream, WritableStream } from '
|
|
1
|
+
import { ReadableStream, WritableStream } from './webstreams.js'
|
|
2
2
|
import { logger } from './utils.js'
|
|
3
3
|
import { WebTransportError } from './error.js'
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const pid = typeof process !== 'undefined' ? process.pid : 0
|
|
6
|
+
const log = logger(`webtransport:http3wtstream(${pid})`)
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* WebTransport stream events
|
|
@@ -10,24 +11,24 @@ const log = logger(`webtransport:http3wtstream(${process.pid})`)
|
|
|
10
11
|
* @typedef {import('./types').StreamRecvSignalEvent} StreamRecvSignalEvent
|
|
11
12
|
* @typedef {import('./types').StreamReadEvent} StreamReadEvent
|
|
12
13
|
* @typedef {import('./types').StreamWriteEvent} StreamWriteEvent
|
|
13
|
-
* @typedef {import('./types').StreamResetEvent} StreamResetEvent
|
|
14
14
|
* @typedef {import('./types').StreamNetworkFinishEvent} StreamNetworkFinishEvent
|
|
15
15
|
*
|
|
16
|
-
* @typedef {import('./types').
|
|
16
|
+
* @typedef {import('./types').NativeHttpWTStream} NativeHttpWTStream
|
|
17
|
+
* @typedef {import('./types').ReadBuffer} ReadBuffer
|
|
17
18
|
*
|
|
18
19
|
* @typedef {import('./dom').WebTransportReceiveStream} WebTransportReceiveStream
|
|
19
20
|
* @typedef {import('./dom').WebTransportSendStream} WebTransportSendStream
|
|
20
21
|
*
|
|
21
|
-
* @typedef {import('./session').
|
|
22
|
+
* @typedef {import('./session').HttpWTSession} HttpWTSession
|
|
22
23
|
*
|
|
23
24
|
* @typedef {import('stream/web').WritableStreamDefaultController} WritableStreamDefaultController
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
export class
|
|
27
|
+
export class HttpWTStream {
|
|
27
28
|
/**
|
|
28
29
|
* @param {object} args
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {NativeHttpWTStream} args.object
|
|
31
|
+
* @param {HttpWTSession} args.parentobj
|
|
31
32
|
* @param {object} args.transport
|
|
32
33
|
* @param {boolean} args.bidirectional
|
|
33
34
|
* @param {boolean} args.incoming
|
|
@@ -41,6 +42,10 @@ export class Http3WTStream {
|
|
|
41
42
|
this.incoming = args.incoming
|
|
42
43
|
this.closed = false
|
|
43
44
|
|
|
45
|
+
if (this.objint.sendInitialParameters) {
|
|
46
|
+
this.objint.sendInitialParameters()
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
/** @type {Promise<void> | null} */
|
|
45
50
|
this.pendingoperation = null
|
|
46
51
|
this.pendingres = null
|
|
@@ -55,12 +60,6 @@ export class Http3WTStream {
|
|
|
55
60
|
this.pendingresRead = null
|
|
56
61
|
|
|
57
62
|
if (this.bidirectional || this.incoming) {
|
|
58
|
-
/** @type {Number} */
|
|
59
|
-
this.incomingbufferfilled = 0
|
|
60
|
-
/** @type {Number} */
|
|
61
|
-
this.incomingbufferreadpos = 0
|
|
62
|
-
if (!this.objint.readbuffer)
|
|
63
|
-
throw new Error('No readbuffer for read stream')
|
|
64
63
|
/** @type {WebTransportReceiveStream} */
|
|
65
64
|
// @ts-expect-error `getStats` property is missing from ReadableStream
|
|
66
65
|
this.readable = new ReadableStream(
|
|
@@ -78,16 +77,11 @@ export class Http3WTStream {
|
|
|
78
77
|
return Promise.resolve()
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
await this.pendingoperationRead
|
|
87
|
-
}
|
|
88
|
-
if (this.incomingbufferfilled === 0) return Promise.resolve()
|
|
89
|
-
|
|
90
|
-
this.drainBuffer()
|
|
80
|
+
this.pendingoperationRead = new Promise((resolve, reject) => {
|
|
81
|
+
this.pendingresRead = resolve
|
|
82
|
+
})
|
|
83
|
+
this.objint.startReading()
|
|
84
|
+
await this.pendingoperationRead
|
|
91
85
|
},
|
|
92
86
|
cancel: (/** @type {{ code: number; }} */ reason) => {
|
|
93
87
|
/** @type {Promise<void>} */
|
|
@@ -131,14 +125,18 @@ export class Http3WTStream {
|
|
|
131
125
|
if (this.writableclosed) {
|
|
132
126
|
return Promise.resolve()
|
|
133
127
|
}
|
|
134
|
-
|
|
128
|
+
let wchunk = chunk
|
|
129
|
+
if (wchunk instanceof ArrayBuffer) {
|
|
130
|
+
wchunk = new Uint8Array(wchunk)
|
|
131
|
+
}
|
|
132
|
+
if (wchunk instanceof Uint8Array) {
|
|
135
133
|
this.pendingoperation = new Promise((resolve, reject) => {
|
|
136
134
|
this.pendingres = resolve
|
|
137
135
|
})
|
|
138
136
|
this.parentobj
|
|
139
137
|
.waitForDatagramsSend()
|
|
140
138
|
.finally(() => {
|
|
141
|
-
this.objint.writeChunk(
|
|
139
|
+
this.objint.writeChunk(wchunk)
|
|
142
140
|
})
|
|
143
141
|
.catch((/** @type {any} */ err) => {
|
|
144
142
|
log.error(err)
|
|
@@ -146,7 +144,9 @@ export class Http3WTStream {
|
|
|
146
144
|
return this.pendingoperation
|
|
147
145
|
} else {
|
|
148
146
|
log.trace('chunk info:', chunk)
|
|
149
|
-
throw new Error(
|
|
147
|
+
throw new Error(
|
|
148
|
+
'chunk is not of instanceof Uint8Array or Arraybuffer'
|
|
149
|
+
)
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
close: () => {
|
|
@@ -199,62 +199,69 @@ export class Http3WTStream {
|
|
|
199
199
|
this.pendingres = null
|
|
200
200
|
/** @type {(() => void) | null} */
|
|
201
201
|
this.abortres = null
|
|
202
|
+
|
|
203
|
+
this.finaldrain_ = false
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
|
|
206
|
+
/**
|
|
207
|
+
* @param {{byteSize: number}} args
|
|
208
|
+
* @returns {ReadBuffer}
|
|
209
|
+
*/
|
|
210
|
+
getReadBuffer({ byteSize }) {
|
|
205
211
|
const byob = this.readableController.byobRequest
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
this.objint.readbuffer.byteLength
|
|
218
|
-
) {
|
|
219
|
-
/** @type {Number} */
|
|
220
|
-
const firstread =
|
|
221
|
-
this.objint.readbuffer.byteLength - this.incomingbufferreadpos
|
|
222
|
-
read += firstread
|
|
223
|
-
toread -= firstread
|
|
224
|
-
const destview = new Uint8Array(
|
|
225
|
-
view.buffer,
|
|
226
|
-
0 + view.byteOffset,
|
|
227
|
-
firstread
|
|
228
|
-
)
|
|
229
|
-
const srcview = new Uint8Array(
|
|
230
|
-
this.objint.readbuffer,
|
|
231
|
-
this.incomingbufferreadpos,
|
|
232
|
-
firstread
|
|
233
|
-
)
|
|
234
|
-
destview.set(srcview)
|
|
235
|
-
this.incomingbufferreadpos = 0
|
|
212
|
+
if (byob) {
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
const buffer = byob?.view
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
if (!(buffer instanceof Uint8Array)) {
|
|
217
|
+
throw new Error('byob view is not a Uint8Array')
|
|
218
|
+
}
|
|
219
|
+
return { buffer, byob, readBytes: 0, fin: false }
|
|
220
|
+
} else {
|
|
221
|
+
const buffer = new Uint8Array(byteSize)
|
|
222
|
+
return { buffer, byob: undefined, readBytes: 0, fin: false }
|
|
236
223
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
read += toread
|
|
250
|
-
this.incomingbufferreadpos =
|
|
251
|
-
(this.incomingbufferreadpos + toread) %
|
|
252
|
-
this.objint.readbuffer.byteLength
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @param {ReadBuffer} args
|
|
228
|
+
*/
|
|
229
|
+
commitReadBuffer({ buffer, byob, drained, readBytes, fin }) {
|
|
230
|
+
if (!this.readableclosed) {
|
|
231
|
+
if (byob && readBytes !== undefined) {
|
|
232
|
+
byob.respond(readBytes)
|
|
233
|
+
} else if (buffer) {
|
|
234
|
+
this.readableController.enqueue(buffer)
|
|
235
|
+
}
|
|
253
236
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
|
|
237
|
+
const retObj = {}
|
|
238
|
+
|
|
239
|
+
if (readBytes !== undefined && readBytes > 0 && !this.readableclosed) {
|
|
240
|
+
log.trace('commitReadbuffer', readBytes)
|
|
241
|
+
// console.log('stream read received', args.data, Date.now())
|
|
242
|
+
if (this.pendingoperationRead && drained) {
|
|
243
|
+
if (this.readableController.desiredSize != null && !this.finaldrain_) {
|
|
244
|
+
if (this.readableController.desiredSize < 0) retObj.stopReading = true
|
|
245
|
+
}
|
|
246
|
+
// this.readableController.enqueue(data)
|
|
247
|
+
const res = this.pendingresRead
|
|
248
|
+
this.pendingoperationRead = null
|
|
249
|
+
this.pendingresRead = null
|
|
250
|
+
if (res) res()
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (fin) {
|
|
254
|
+
if (this.cancelres) {
|
|
255
|
+
const res = this.cancelres
|
|
256
|
+
this.cancelres = null
|
|
257
|
+
res()
|
|
258
|
+
}
|
|
259
|
+
if (!this.readableclosed) {
|
|
260
|
+
this.readableController.close()
|
|
261
|
+
this.readableclosed = true
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return retObj
|
|
258
265
|
}
|
|
259
266
|
|
|
260
267
|
/**
|
|
@@ -262,7 +269,7 @@ export class Http3WTStream {
|
|
|
262
269
|
* @returns {void}
|
|
263
270
|
*/
|
|
264
271
|
onStreamRecvSignal(args) {
|
|
265
|
-
log('callback', args?.
|
|
272
|
+
log('callback', args?.nettask)
|
|
266
273
|
log.trace('onStreamRecvSignal', args)
|
|
267
274
|
// check if transport is closed
|
|
268
275
|
let parentcleanup = true
|
|
@@ -274,6 +281,7 @@ export class Http3WTStream {
|
|
|
274
281
|
switch (args.nettask) {
|
|
275
282
|
case 'resetStream':
|
|
276
283
|
if (this.readable) {
|
|
284
|
+
this.finalDrain()
|
|
277
285
|
if (parentcleanup)
|
|
278
286
|
this.parentobj.removeReceiveStream(
|
|
279
287
|
this.readable,
|
|
@@ -326,46 +334,9 @@ export class Http3WTStream {
|
|
|
326
334
|
}
|
|
327
335
|
}
|
|
328
336
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
*/
|
|
333
|
-
onStreamRead(args) {
|
|
334
|
-
if (args.buffergrow && !this.readableclosed) {
|
|
335
|
-
log.trace('stream read received', args.buffergrow)
|
|
336
|
-
this.incomingbufferfilled += args.buffergrow
|
|
337
|
-
// console.log('stream read received', args.data, Date.now())
|
|
338
|
-
if (this.pendingoperationRead) {
|
|
339
|
-
// this.readableController.enqueue(data)
|
|
340
|
-
const res = this.pendingresRead
|
|
341
|
-
this.pendingoperationRead = null
|
|
342
|
-
this.pendingresRead = null
|
|
343
|
-
if (res) res()
|
|
344
|
-
}
|
|
345
|
-
if (
|
|
346
|
-
this.readableController.desiredSize != null &&
|
|
347
|
-
this.readableController.desiredSize < 0
|
|
348
|
-
)
|
|
349
|
-
this.objint.stopReading()
|
|
350
|
-
}
|
|
351
|
-
if (args.fin) {
|
|
352
|
-
if (this.incomingbufferfilled > 0) {
|
|
353
|
-
log.trace('Warning buffer filled and we got a fin')
|
|
354
|
-
if (this.pendingoperationRead || this.pendingresRead)
|
|
355
|
-
throw new Error('We have pendingoperationRead and a filled buffer?')
|
|
356
|
-
|
|
357
|
-
this.drainBuffer()
|
|
358
|
-
}
|
|
359
|
-
if (this.cancelres) {
|
|
360
|
-
const res = this.cancelres
|
|
361
|
-
this.cancelres = null
|
|
362
|
-
res()
|
|
363
|
-
}
|
|
364
|
-
if (!this.readableclosed) {
|
|
365
|
-
this.readableController.close()
|
|
366
|
-
this.readableclosed = true
|
|
367
|
-
}
|
|
368
|
-
}
|
|
337
|
+
finalDrain() {
|
|
338
|
+
this.finaldrain_ = true
|
|
339
|
+
this.objint.drainReads()
|
|
369
340
|
}
|
|
370
341
|
|
|
371
342
|
/**
|
|
@@ -383,29 +354,11 @@ export class Http3WTStream {
|
|
|
383
354
|
}
|
|
384
355
|
}
|
|
385
356
|
|
|
386
|
-
/**
|
|
387
|
-
* @param {StreamResetEvent} args
|
|
388
|
-
*/
|
|
389
|
-
onStreamReset(args) {
|
|
390
|
-
if (this.abortres) {
|
|
391
|
-
this.abortres()
|
|
392
|
-
if (this.readable)
|
|
393
|
-
this.parentobj.removeReceiveStream(
|
|
394
|
-
this.readable,
|
|
395
|
-
this.readableController
|
|
396
|
-
)
|
|
397
|
-
if (this.writable)
|
|
398
|
-
this.parentobj.removeSendStream(this.writable, this.writableController)
|
|
399
|
-
this.readableclosed = true
|
|
400
|
-
this.parentobj.removeStreamObj(this)
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
357
|
/**
|
|
405
358
|
* @param {StreamNetworkFinishEvent} args
|
|
406
359
|
*/
|
|
407
360
|
onStreamNetworkFinish(args) {
|
|
408
|
-
log('callback', args?.
|
|
361
|
+
log('callback', args?.nettask)
|
|
409
362
|
log.trace('networkfinish args', args)
|
|
410
363
|
switch (args.nettask) {
|
|
411
364
|
case 'stopSending':
|
|
@@ -421,6 +374,18 @@ export class Http3WTStream {
|
|
|
421
374
|
const res = this.abortres
|
|
422
375
|
this.abortres = null
|
|
423
376
|
res()
|
|
377
|
+
if (this.readable)
|
|
378
|
+
this.parentobj.removeReceiveStream(
|
|
379
|
+
this.readable,
|
|
380
|
+
this.readableController
|
|
381
|
+
)
|
|
382
|
+
if (this.writable)
|
|
383
|
+
this.parentobj.removeSendStream(
|
|
384
|
+
this.writable,
|
|
385
|
+
this.writableController
|
|
386
|
+
)
|
|
387
|
+
this.readableclosed = true
|
|
388
|
+
this.parentobj.removeStreamObj(this)
|
|
424
389
|
}
|
|
425
390
|
|
|
426
391
|
break
|
|
@@ -440,45 +405,4 @@ export class Http3WTStream {
|
|
|
440
405
|
}
|
|
441
406
|
// we could differentiate....
|
|
442
407
|
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @param {StreamRecvSignalEvent | StreamReadEvent | StreamWriteEvent | StreamResetEvent | StreamNetworkFinishEvent} args
|
|
446
|
-
*/
|
|
447
|
-
static callback(args) {
|
|
448
|
-
log('callback', args?.purpose)
|
|
449
|
-
log.trace(log)
|
|
450
|
-
if (!args || !args.object || !args.object.jsobj)
|
|
451
|
-
throw new Error('Stream callback without jsobj')
|
|
452
|
-
const visitor = args.object.jsobj
|
|
453
|
-
if (args.purpose) {
|
|
454
|
-
switch (args.purpose) {
|
|
455
|
-
case 'StreamRecvSignal':
|
|
456
|
-
visitor.onStreamRecvSignal(args)
|
|
457
|
-
break
|
|
458
|
-
case 'StreamRead':
|
|
459
|
-
if (
|
|
460
|
-
visitor &&
|
|
461
|
-
Object.prototype.hasOwnProperty.call(args, 'buffergrow')
|
|
462
|
-
) {
|
|
463
|
-
visitor.onStreamRead(args)
|
|
464
|
-
} else {
|
|
465
|
-
throw new Error('Malformed StreamRead')
|
|
466
|
-
}
|
|
467
|
-
break
|
|
468
|
-
case 'StreamWrite':
|
|
469
|
-
visitor.onStreamWrite(args)
|
|
470
|
-
break
|
|
471
|
-
case 'StreamReset':
|
|
472
|
-
visitor.onStreamReset(args)
|
|
473
|
-
break
|
|
474
|
-
case 'StreamNetworkFinish':
|
|
475
|
-
visitor.onStreamNetworkFinish(args)
|
|
476
|
-
|
|
477
|
-
break
|
|
478
|
-
default: {
|
|
479
|
-
throw new Error('unknown purpose Streamcb')
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
} else throw new Error('no purpose Streamcb')
|
|
483
|
-
}
|
|
484
408
|
}
|