nish 0.35.0 → 0.37.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/docs/AI.md +50 -4
- package/docs/INSTALL.md +73 -59
- package/package.json +19 -5
- package/runtime/async.d.mts +2 -0
- package/runtime/async.mjs +7 -0
- package/runtime/nish.d.ts +4849 -430
- package/runtime/nish.h +25 -0
- package/runtime/page.d.ts +53 -0
- package/runtime/page.mjs +146 -0
- package/runtime/runtime-async.c +557 -0
- package/runtime/runtime-wasm.c +63 -7
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +252 -15
- package/scripts/fuzz.sh +1 -0
- package/scripts/undocumented.txt +14 -0
- package/std/README.md +107 -82
- package/std/base64.ts +34 -5
- package/std/bytes.ts +279 -59
- package/std/cli-args.ts +296 -70
- package/std/cli-flags.ts +184 -19
- package/std/cli.ts +475 -54
- package/std/collections.ts +121 -23
- package/std/compress/checksum.ts +44 -14
- package/std/compress/deflate.ts +224 -111
- package/std/compress/gzip.ts +217 -53
- package/std/compress/zlib.ts +63 -7
- package/std/crypto/aes.ts +128 -52
- package/std/crypto/base64url.ts +29 -5
- package/std/crypto/bcrypt-batch.ts +101 -34
- package/std/crypto/bcrypt.ts +93 -27
- package/std/crypto/chacha20poly1305.ts +69 -14
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +66 -16
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +242 -37
- package/std/crypto/jwt.ts +204 -72
- package/std/crypto/p256.ts +222 -72
- package/std/crypto/p384.ts +51 -23
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +99 -30
- package/std/crypto/rsa.ts +56 -22
- package/std/crypto/sha1.ts +3 -0
- package/std/crypto/sha256.ts +24 -1
- package/std/crypto/sha512.ts +99 -14
- package/std/crypto/x25519.ts +163 -24
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +133 -66
- package/std/host/ring.ts +124 -0
- package/std/json-equal.ts +31 -11
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +76 -26
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +126 -51
- package/std/json-typed.ts +757 -96
- package/std/json-value.ts +438 -157
- package/std/json.ts +170 -38
- package/std/map.ts +25 -7
- package/std/math.ts +36 -4
- package/std/net/buffer-pool.ts +42 -11
- package/std/net/dns-config.ts +109 -23
- package/std/net/dns-message.ts +62 -7
- package/std/net/dns-resolver.ts +247 -53
- package/std/net/dns.ts +203 -35
- package/std/net/fetch.ts +1267 -290
- package/std/net/handler.ts +296 -80
- package/std/net/hpack.ts +290 -77
- package/std/net/http-compress.ts +152 -36
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +129 -44
- package/std/net/http1-codec.ts +279 -114
- package/std/net/http1-server.ts +409 -139
- package/std/net/http2-frame.ts +289 -51
- package/std/net/http2-tls.ts +152 -49
- package/std/net/http2.ts +314 -160
- package/std/net/http3-frame.ts +165 -27
- package/std/net/http3-server.ts +282 -131
- package/std/net/http3.ts +377 -173
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +898 -260
- package/std/net/prefork.ts +202 -65
- package/std/net/qpack.ts +120 -32
- package/std/net/quic-conn-ack.ts +60 -12
- package/std/net/quic-conn-cid.ts +135 -27
- package/std/net/quic-conn-params.ts +109 -22
- package/std/net/quic-datagram.ts +50 -3
- package/std/net/quic-frame.ts +333 -23
- package/std/net/quic-listener.ts +161 -75
- package/std/net/quic-packet.ts +373 -73
- package/std/net/quic-recovery.ts +287 -65
- package/std/net/quic-stream.ts +436 -146
- package/std/net/quic.ts +693 -323
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +167 -51
- package/std/net/tls/codec.ts +494 -68
- package/std/net/tls/record-client.ts +140 -73
- package/std/net/tls/record-server.ts +233 -105
- package/std/net/tls/record.ts +142 -36
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +161 -40
- package/std/net/tls/verify.ts +57 -10
- package/std/net/tls-tcp.ts +308 -95
- package/std/net/tls.ts +276 -102
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +109 -22
- package/std/net/websocket.ts +140 -26
- package/std/net/webtransport.ts +243 -106
- package/std/pair.ts +10 -2
- package/std/random.ts +42 -15
- package/std/regex.ts +422 -257
- package/std/region.ts +70 -15
- package/std/secret.ts +52 -11
- package/std/sort.ts +17 -2
- package/std/sqlite.ts +256 -35
- package/std/sync/ring.ts +229 -56
- package/std/sync/shm.ts +203 -23
- package/std/term-io.ts +154 -78
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +77 -35
- package/std/term-rate.ts +199 -118
- package/std/term.ts +400 -175
- package/std/testing.ts +130 -32
- package/std/text.ts +84 -17
- package/std/threads.ts +248 -56
- package/std/yaml-json.ts +111 -97
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +45 -30
- package/std/yaml.ts +764 -384
package/std/net/http2-frame.ts
CHANGED
|
@@ -8,34 +8,42 @@
|
|
|
8
8
|
* the caller reuses, its content left where it lies as a window, and a frame
|
|
9
9
|
* is written into the caller's buffer at an offset.
|
|
10
10
|
*
|
|
11
|
-
* import {
|
|
11
|
+
* import {
|
|
12
|
+
* H2_FLAG_END_STREAM, Http2Frame, http2ReadHeader, http2ParseFrame, http2WriteData,
|
|
13
|
+
* } from "nish/net/http2-frame";
|
|
12
14
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* // `buf[off, off + len)` is what the peer sent; `maxFrameSize` is this side's SETTINGS_MAX_FRAME_SIZE.
|
|
16
|
+
* const read = (frame: Http2Frame, buf: u8[], off: i32, len: i32, maxFrameSize: i32): void => {
|
|
17
|
+
* if (http2ReadHeader(frame, buf, off, len) && len >= 9 + frame.length) {
|
|
18
|
+
* const error: i32 = http2ParseFrame(frame, buf, off, maxFrameSize);
|
|
19
|
+
* // 0, or the connection error to close with; frame.streamError, the
|
|
20
|
+
* // stream error to reset the stream with; then buf[frame.contentStart ..
|
|
21
|
+
* // frame.contentStart + frame.contentLength) is the DATA, the header
|
|
22
|
+
* // block fragment or the GOAWAY debug data.
|
|
23
|
+
* }
|
|
24
|
+
* };
|
|
25
|
+
* // `body[0, n)` goes into `out` at `at` as the last DATA of `streamId`; `end` is the offset after it.
|
|
26
|
+
* const send = (out: u8[], at: i32, streamId: i32, body: u8[], n: i32): void => {
|
|
27
|
+
* const end: i32 = http2WriteData(out, at, streamId, body, 0, n, H2_FLAG_END_STREAM, -1);
|
|
28
|
+
* };
|
|
22
29
|
*
|
|
23
|
-
* **What a parse refuses**, as the error code RFC 9113 names, which closes
|
|
24
|
-
*
|
|
25
|
-
* (FRAME_SIZE_ERROR, §4.2); DATA, HEADERS, PRIORITY, RST_STREAM,
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
30
|
+
* **What a parse refuses**, as the error code RFC 9113 names, which closes the
|
|
31
|
+
* connection: a frame longer than the receiver's SETTINGS_MAX_FRAME_SIZE
|
|
32
|
+
* (FRAME_SIZE_ERROR, §4.2); DATA, HEADERS, PRIORITY, RST_STREAM, PUSH_PROMISE
|
|
33
|
+
* or CONTINUATION on stream 0, and SETTINGS, PING or GOAWAY on any other
|
|
34
|
+
* (PROTOCOL_ERROR); a frame too short for its fixed fields, a RST_STREAM or
|
|
35
|
+
* WINDOW_UPDATE that is not four bytes, a PING that is not eight, a SETTINGS
|
|
36
|
+
* whose length is not a multiple of six or an ACK with a payload, and a GOAWAY
|
|
37
|
+
* under eight (FRAME_SIZE_ERROR); padding as long as what it pads or longer
|
|
38
|
+
* (PROTOCOL_ERROR, §6.1); and a WINDOW_UPDATE of zero on the connection
|
|
39
|
+
* (PROTOCOL_ERROR, §6.9).
|
|
40
|
+
*
|
|
41
|
+
* Two refusals only reset the stream, and come back in `streamError` with a
|
|
42
|
+
* parse that answers 0: a PRIORITY of the wrong length (FRAME_SIZE_ERROR,
|
|
43
|
+
* §6.3), and a WINDOW_UPDATE of zero on a stream (PROTOCOL_ERROR). A HEADERS or
|
|
44
|
+
* PRIORITY that makes a stream depend on itself is the same (PROTOCOL_ERROR,
|
|
45
|
+
* §5.3.1). A frame of a type this module does not know is read and answers 0:
|
|
46
|
+
* §4.1 says it is ignored, and that is the connection's to do.
|
|
39
47
|
*
|
|
40
48
|
* SETTINGS values are checked one at a time by `http2SettingError`, because
|
|
41
49
|
* which value a refusal names is the reader's business (§6.5.2): an
|
|
@@ -46,8 +54,10 @@
|
|
|
46
54
|
* **The writers** answer the offset after the frame, or -1 when it would not
|
|
47
55
|
* fit in the buffer, which is then unchanged; a window outside its source
|
|
48
56
|
* buffer, a stream identifier outside 0 to 2^31 − 1 and padding past 255 are
|
|
49
|
-
* the program's mistakes and panic.
|
|
50
|
-
*
|
|
57
|
+
* the program's mistakes and panic. The writers of a frame type write none
|
|
58
|
+
* the reader refuses, so a program cannot send what its peer must close for,
|
|
59
|
+
* save a payload past the peer's SETTINGS_MAX_FRAME_SIZE, which they cannot
|
|
60
|
+
* know: they stop at 2^24 − 1. `http2WriteHeader` checks no type's rules.
|
|
51
61
|
*
|
|
52
62
|
* Private helpers share the importing program's flat symbol namespace
|
|
53
63
|
* (`docs/wp26-stdlib.md` §3e), which is why each one carries the module's name.
|
|
@@ -58,20 +68,30 @@
|
|
|
58
68
|
/** The size of a frame header: a 24-bit length, a type, flags and a 31-bit stream identifier (§4.1). */
|
|
59
69
|
export const H2_FRAME_HEADER_SIZE: i32 = 9
|
|
60
70
|
|
|
61
|
-
/** The frame types of §6. */
|
|
71
|
+
/** The frame types of §6, the header's type byte. DATA (0x0): a stream's body bytes (§6.1). */
|
|
62
72
|
export const H2_FRAME_DATA: i32 = 0
|
|
73
|
+
/** HEADERS (0x1): opens a stream with a header block fragment, or carries trailers (§6.2). */
|
|
63
74
|
export const H2_FRAME_HEADERS: i32 = 1
|
|
75
|
+
/** PRIORITY (0x2): a stream's dependency and weight, a scheme RFC 9113 deprecates (§6.3, §5.3.2). */
|
|
64
76
|
export const H2_FRAME_PRIORITY: i32 = 2
|
|
77
|
+
/** RST_STREAM (0x3): ends one stream at once with an error code (§6.4). */
|
|
65
78
|
export const H2_FRAME_RST_STREAM: i32 = 3
|
|
79
|
+
/** SETTINGS (0x4): the sender's settings, or with ACK their acknowledgement (§6.5). */
|
|
66
80
|
export const H2_FRAME_SETTINGS: i32 = 4
|
|
81
|
+
/** PUSH_PROMISE (0x5): reserves a stream for a server push, with its request's header block (§6.6). */
|
|
67
82
|
export const H2_FRAME_PUSH_PROMISE: i32 = 5
|
|
83
|
+
/** PING (0x6): eight opaque bytes the peer echoes back with ACK (§6.7). */
|
|
68
84
|
export const H2_FRAME_PING: i32 = 6
|
|
85
|
+
/** GOAWAY (0x7): the sender is going away; names the last stream it may have processed (§6.8). */
|
|
69
86
|
export const H2_FRAME_GOAWAY: i32 = 7
|
|
87
|
+
/** WINDOW_UPDATE (0x8): widens a stream's or the connection's flow-control window (§6.9). */
|
|
70
88
|
export const H2_FRAME_WINDOW_UPDATE: i32 = 8
|
|
89
|
+
/** CONTINUATION (0x9): the next fragment of a header block a HEADERS or PUSH_PROMISE began (§6.10). */
|
|
71
90
|
export const H2_FRAME_CONTINUATION: i32 = 9
|
|
72
91
|
|
|
73
|
-
/** END_STREAM on DATA and HEADERS
|
|
92
|
+
/** END_STREAM (0x1) on DATA and HEADERS: the sender's last frame on the stream. */
|
|
74
93
|
export const H2_FLAG_END_STREAM: i32 = 1
|
|
94
|
+
/** ACK (0x1) on SETTINGS and PING, the same bit as END_STREAM: the frame acknowledges the peer's. */
|
|
75
95
|
export const H2_FLAG_ACK: i32 = 1
|
|
76
96
|
/** END_HEADERS on HEADERS, PUSH_PROMISE and CONTINUATION. */
|
|
77
97
|
export const H2_FLAG_END_HEADERS: i32 = 4
|
|
@@ -80,37 +100,61 @@ export const H2_FLAG_PADDED: i32 = 8
|
|
|
80
100
|
/** PRIORITY on HEADERS. */
|
|
81
101
|
export const H2_FLAG_PRIORITY: i32 = 32
|
|
82
102
|
|
|
83
|
-
/** The error codes of §7. */
|
|
103
|
+
/** The error codes of §7. NO_ERROR (0x0): not an error, as in a graceful GOAWAY; the parsers' "accepted". */
|
|
84
104
|
export const H2_NO_ERROR: i32 = 0
|
|
105
|
+
/** PROTOCOL_ERROR (0x1): a generic protocol violation (§7). */
|
|
85
106
|
export const H2_PROTOCOL_ERROR: i32 = 1
|
|
107
|
+
/** INTERNAL_ERROR (0x2): the sender hit an unexpected internal error (§7). */
|
|
86
108
|
export const H2_INTERNAL_ERROR: i32 = 2
|
|
109
|
+
/** FLOW_CONTROL_ERROR (0x3): the peer broke flow control (§7). */
|
|
87
110
|
export const H2_FLOW_CONTROL_ERROR: i32 = 3
|
|
111
|
+
/** SETTINGS_TIMEOUT (0x4): a SETTINGS was not acknowledged in time (§7). */
|
|
88
112
|
export const H2_SETTINGS_TIMEOUT: i32 = 4
|
|
113
|
+
/** STREAM_CLOSED (0x5): a frame arrived on a stream that was half-closed for it (§7). */
|
|
89
114
|
export const H2_STREAM_CLOSED: i32 = 5
|
|
115
|
+
/** FRAME_SIZE_ERROR (0x6): a frame had an invalid size (§7). */
|
|
90
116
|
export const H2_FRAME_SIZE_ERROR: i32 = 6
|
|
117
|
+
/** REFUSED_STREAM (0x7): the stream was refused before any of it was processed; it may be retried (§7). */
|
|
91
118
|
export const H2_REFUSED_STREAM: i32 = 7
|
|
119
|
+
/** CANCEL (0x8): the stream is no longer needed (§7). */
|
|
92
120
|
export const H2_CANCEL: i32 = 8
|
|
121
|
+
/** COMPRESSION_ERROR (0x9): the field-compression context cannot be kept (§7). */
|
|
93
122
|
export const H2_COMPRESSION_ERROR: i32 = 9
|
|
123
|
+
/** CONNECT_ERROR (0xa): the connection a CONNECT request made was reset or closed (§7). */
|
|
94
124
|
export const H2_CONNECT_ERROR: i32 = 10
|
|
125
|
+
/** ENHANCE_YOUR_CALM (0xb): the peer is generating excessive load (§7). */
|
|
95
126
|
export const H2_ENHANCE_YOUR_CALM: i32 = 11
|
|
127
|
+
/** INADEQUATE_SECURITY (0xc): the transport does not meet the minimum security requirements (§7). */
|
|
96
128
|
export const H2_INADEQUATE_SECURITY: i32 = 12
|
|
129
|
+
/** HTTP_1_1_REQUIRED (0xd): the endpoint requires HTTP/1.1 instead of HTTP/2 (§7). */
|
|
97
130
|
export const H2_HTTP_1_1_REQUIRED: i32 = 13
|
|
98
131
|
|
|
99
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* The settings of §6.5.2, and RFC 8441's, by identifier. SETTINGS_HEADER_TABLE_SIZE (0x1): the most
|
|
134
|
+
* bytes of HPACK dynamic table the sender lets its peer's encoder use.
|
|
135
|
+
*/
|
|
100
136
|
export const H2_SETTINGS_HEADER_TABLE_SIZE: i32 = 1
|
|
137
|
+
/** SETTINGS_ENABLE_PUSH (0x2): 0 or 1, whether the sender allows server push. */
|
|
101
138
|
export const H2_SETTINGS_ENABLE_PUSH: i32 = 2
|
|
139
|
+
/** SETTINGS_MAX_CONCURRENT_STREAMS (0x3): the most streams the sender lets its peer open at once. */
|
|
102
140
|
export const H2_SETTINGS_MAX_CONCURRENT_STREAMS: i32 = 3
|
|
141
|
+
/** SETTINGS_INITIAL_WINDOW_SIZE (0x4): every stream's initial send window, in bytes, 0 to 2^31 − 1. */
|
|
103
142
|
export const H2_SETTINGS_INITIAL_WINDOW_SIZE: i32 = 4
|
|
143
|
+
/** SETTINGS_MAX_FRAME_SIZE (0x5): the longest frame payload the sender takes, 2^14 to 2^24 − 1 bytes. */
|
|
104
144
|
export const H2_SETTINGS_MAX_FRAME_SIZE: i32 = 5
|
|
145
|
+
/** SETTINGS_MAX_HEADER_LIST_SIZE (0x6): advisory, the largest field section the sender takes (§6.5.2). */
|
|
105
146
|
export const H2_SETTINGS_MAX_HEADER_LIST_SIZE: i32 = 6
|
|
147
|
+
/** SETTINGS_ENABLE_CONNECT_PROTOCOL (0x8): 0 or 1, whether the sender takes extended CONNECT (RFC 8441). */
|
|
106
148
|
export const H2_SETTINGS_ENABLE_CONNECT_PROTOCOL: i32 = 8
|
|
107
149
|
|
|
108
|
-
/** A window's initial size,
|
|
150
|
+
/** A window's initial size, 65,535 bytes, on the connection and on every stream (§6.9.2). */
|
|
109
151
|
export const H2_DEFAULT_WINDOW: i32 = 65535
|
|
152
|
+
/** The largest a window may reach, and the largest INITIAL_WINDOW_SIZE: 2^31 − 1 bytes (§6.9.1). */
|
|
110
153
|
export const H2_MAX_WINDOW: i32 = 2147483647
|
|
111
154
|
|
|
112
|
-
/** SETTINGS_MAX_FRAME_SIZE's initial value, which is also its least
|
|
155
|
+
/** SETTINGS_MAX_FRAME_SIZE's initial value, which is also its least: 2^14 bytes (§6.5.2). */
|
|
113
156
|
export const H2_DEFAULT_MAX_FRAME: i32 = 16384
|
|
157
|
+
/** SETTINGS_MAX_FRAME_SIZE's greatest value, 2^24 − 1 bytes; a writer panics past it (§6.5.2). */
|
|
114
158
|
export const H2_MAX_FRAME_LIMIT: i32 = 16777215
|
|
115
159
|
|
|
116
160
|
/** The size of one setting: a 16-bit identifier and a 32-bit value. */
|
|
@@ -132,17 +176,28 @@ const H2_FRAME_EXCLUSIVE: i64 = 2147483648
|
|
|
132
176
|
const H2_FRAME_U32_MAX: i64 = 4294967295
|
|
133
177
|
|
|
134
178
|
/**
|
|
135
|
-
* One frame, as `http2ReadHeader` and `http2ParseFrame` read it.
|
|
136
|
-
*
|
|
179
|
+
* One frame, as `http2ReadHeader` and `http2ParseFrame` read it. The next
|
|
180
|
+
* header read overwrites the header's fields; the next parse overwrites the
|
|
181
|
+
* content window, the padding and priority fields and `streamError`, and a
|
|
182
|
+
* type's own fields when it parses that type. A field only another type
|
|
183
|
+
* carries (`errorCode`, `lastStreamId`, `increment`, `promisedId`) keeps its
|
|
184
|
+
* last value, so a reader reads the fields of the type it parsed. One frame
|
|
185
|
+
* serves a whole connection.
|
|
137
186
|
*/
|
|
138
187
|
export class Http2Frame {
|
|
139
188
|
/** The payload's length, from the header. */
|
|
140
189
|
length: i32 = 0
|
|
190
|
+
/** The frame type from the header, 0 to 255: an `H2_FRAME_*`, or a type this module does not know. */
|
|
141
191
|
type: i32 = 0
|
|
192
|
+
/** The flags byte from the header, as sent, bits a type does not define included; `has` tests one. */
|
|
142
193
|
flags: i32 = 0
|
|
143
194
|
/** The stream identifier, the reserved bit dropped. */
|
|
144
195
|
streamId: i32 = 0
|
|
145
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Where the payload starts in the buffer read.
|
|
198
|
+
*
|
|
199
|
+
* @internal Read by this module's parse and setting readers; a caller reads `contentStart`.
|
|
200
|
+
*/
|
|
146
201
|
payload: i32 = 0
|
|
147
202
|
/**
|
|
148
203
|
* The frame's content, `[contentStart, contentStart + contentLength)` of the
|
|
@@ -150,12 +205,18 @@ export class Http2Frame {
|
|
|
150
205
|
* debug data, SETTINGS' settings; padding and fixed fields left out.
|
|
151
206
|
*/
|
|
152
207
|
contentStart: i32 = 0
|
|
208
|
+
/**
|
|
209
|
+
* The content's length in bytes, from `contentStart`. For every type but DATA, HEADERS,
|
|
210
|
+
* PUSH_PROMISE and GOAWAY, the window is the whole payload.
|
|
211
|
+
*/
|
|
153
212
|
contentLength: i32 = 0
|
|
154
213
|
/** The Pad Length field, or -1 without PADDED. */
|
|
155
214
|
padLength: i32 = -1
|
|
156
215
|
/** Whether a HEADERS frame carried the PRIORITY fields, as a PRIORITY frame always does. */
|
|
157
216
|
hasPriority: boolean = false
|
|
217
|
+
/** Whether the stream dependency is exclusive (§5.3.1); false without priority fields. */
|
|
158
218
|
exclusive: boolean = false
|
|
219
|
+
/** The stream this one depends on, the exclusive bit dropped; 0 without priority fields. */
|
|
159
220
|
dependency: i32 = 0
|
|
160
221
|
/** The weight, 1 to 256. */
|
|
161
222
|
weight: i32 = 0
|
|
@@ -170,7 +231,12 @@ export class Http2Frame {
|
|
|
170
231
|
/** A stream error the frame is, or 0: the stream is reset and the connection lives. */
|
|
171
232
|
streamError: i32 = 0
|
|
172
233
|
|
|
173
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Whether the flag `bit` is set.
|
|
236
|
+
*
|
|
237
|
+
* @param bit A flag mask, an `H2_FLAG_*`.
|
|
238
|
+
* @returns True when `flags` has any bit of `bit` set.
|
|
239
|
+
*/
|
|
174
240
|
has(bit: i32): boolean {
|
|
175
241
|
return (this.flags & bit) !== 0
|
|
176
242
|
}
|
|
@@ -213,6 +279,14 @@ const http2FramePut32 = (out: u8[], at: i32, value: i64): void => {
|
|
|
213
279
|
* `off` hold one, and answers whether they did. The payload need not be there
|
|
214
280
|
* yet: a reader checks `frame.length` against its limit before it waits for
|
|
215
281
|
* the rest, which is what keeps a peer from making it buffer more.
|
|
282
|
+
*
|
|
283
|
+
* @param frame The frame its length, type, flags and stream identifier are written into; left as it was
|
|
284
|
+
* when the header is not all there.
|
|
285
|
+
* @param buf The bytes received, read and not kept.
|
|
286
|
+
* @param off Where the header starts in `buf`.
|
|
287
|
+
* @param len How many bytes from `off` have arrived; `[off, off + len)` outside `buf` panics.
|
|
288
|
+
* @returns True when nine bytes were there and the header was read; false when fewer were, with `frame`
|
|
289
|
+
* untouched, so the reader waits for more.
|
|
216
290
|
*/
|
|
217
291
|
export const http2ReadHeader = (frame: Http2Frame, buf: u8[], off: i32, len: i32): boolean => {
|
|
218
292
|
http2FrameCheckWindow("http2ReadHeader", buf, off, len)
|
|
@@ -266,6 +340,16 @@ const http2FramePriority = (frame: Http2Frame, buf: u8[], at: i32): void => {
|
|
|
266
340
|
* SETTINGS_MAX_FRAME_SIZE. Answers 0, with the type's fields set and any
|
|
267
341
|
* stream error in `streamError`, or the connection error the module comment
|
|
268
342
|
* lists.
|
|
343
|
+
*
|
|
344
|
+
* @param frame The frame `http2ReadHeader` filled from the same `buf` and `off`; its content window,
|
|
345
|
+
* padding, priority fields, `streamError` and the parsed type's own fields are set.
|
|
346
|
+
* @param buf The bytes received; the content window points into it, so it must stay as it is while the
|
|
347
|
+
* content is read. `[off, off + 9 + frame.length)` outside `buf` panics.
|
|
348
|
+
* @param off Where the frame's header starts in `buf`.
|
|
349
|
+
* @param maxFrameSize This side's SETTINGS_MAX_FRAME_SIZE in bytes; a longer payload is refused.
|
|
350
|
+
* @returns 0 (`H2_NO_ERROR`) when the frame is accepted, `streamError` then holding 0 or the stream error
|
|
351
|
+
* to reset with (`H2_FRAME_SIZE_ERROR` or `H2_PROTOCOL_ERROR`); otherwise the connection error to close
|
|
352
|
+
* with, `H2_FRAME_SIZE_ERROR` or `H2_PROTOCOL_ERROR`.
|
|
269
353
|
*/
|
|
270
354
|
export const http2ParseFrame = (frame: Http2Frame, buf: u8[], off: i32, maxFrameSize: i32): i32 => {
|
|
271
355
|
http2FrameCheckWindow("http2ParseFrame", buf, off, H2_FRAME_HEADER_SIZE + frame.length)
|
|
@@ -370,16 +454,35 @@ export const http2ParseFrame = (frame: Http2Frame, buf: u8[], off: i32, maxFrame
|
|
|
370
454
|
}
|
|
371
455
|
}
|
|
372
456
|
|
|
373
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* How many settings a SETTINGS frame `http2ParseFrame` accepted carries.
|
|
459
|
+
*
|
|
460
|
+
* @param frame The SETTINGS frame just parsed.
|
|
461
|
+
* @returns The payload's length over six: 0 for an ACK or an empty SETTINGS.
|
|
462
|
+
*/
|
|
374
463
|
export const http2SettingCount = (frame: Http2Frame): i32 => frame.length / H2_SETTING_SIZE
|
|
375
464
|
|
|
376
|
-
/**
|
|
465
|
+
/**
|
|
466
|
+
* The identifier of setting `k` of the SETTINGS frame in `buf`.
|
|
467
|
+
*
|
|
468
|
+
* @param frame The SETTINGS frame `http2ParseFrame` accepted.
|
|
469
|
+
* @param buf The buffer that frame was read from, unchanged since.
|
|
470
|
+
* @param k Which setting, 0 to `http2SettingCount(frame)` − 1; nothing here checks the bound.
|
|
471
|
+
* @returns The 16-bit identifier, 0 to 65,535: an `H2_SETTINGS_*`, or one this module does not know.
|
|
472
|
+
*/
|
|
377
473
|
export const http2SettingId = (frame: Http2Frame, buf: u8[], k: i32): i32 => {
|
|
378
474
|
const at: i32 = frame.payload + k * H2_SETTING_SIZE
|
|
379
475
|
return (toI32(buf[at]) << 8) | toI32(buf[at + 1])
|
|
380
476
|
}
|
|
381
477
|
|
|
382
|
-
/**
|
|
478
|
+
/**
|
|
479
|
+
* The value of setting `k` of the SETTINGS frame in `buf`.
|
|
480
|
+
*
|
|
481
|
+
* @param frame The SETTINGS frame `http2ParseFrame` accepted.
|
|
482
|
+
* @param buf The buffer that frame was read from, unchanged since.
|
|
483
|
+
* @param k Which setting, 0 to `http2SettingCount(frame)` − 1; nothing here checks the bound.
|
|
484
|
+
* @returns The value as sent, 0 to 2^32 − 1, not yet checked: `http2SettingError` checks it.
|
|
485
|
+
*/
|
|
383
486
|
export const http2SettingValue = (frame: Http2Frame, buf: u8[], k: i32): i64 =>
|
|
384
487
|
http2FrameU32(buf, frame.payload + k * H2_SETTING_SIZE + 2)
|
|
385
488
|
|
|
@@ -387,6 +490,12 @@ export const http2SettingValue = (frame: Http2Frame, buf: u8[], k: i32): i64 =>
|
|
|
387
490
|
* The connection error a setting's value is, or 0 (§6.5.2, RFC 8441 §3). A
|
|
388
491
|
* setting this module does not know is not an error: §6.5.2 says it is
|
|
389
492
|
* ignored.
|
|
493
|
+
*
|
|
494
|
+
* @param id The setting's identifier, as `http2SettingId` reads it.
|
|
495
|
+
* @param value The setting's value, as `http2SettingValue` reads it, 0 to 2^32 − 1.
|
|
496
|
+
* @returns `H2_PROTOCOL_ERROR` for an ENABLE_PUSH or ENABLE_CONNECT_PROTOCOL above 1 or a MAX_FRAME_SIZE
|
|
497
|
+
* outside 2^14 to 2^24 − 1; `H2_FLOW_CONTROL_ERROR` for an INITIAL_WINDOW_SIZE above 2^31 − 1;
|
|
498
|
+
* otherwise 0, every other identifier included.
|
|
390
499
|
*/
|
|
391
500
|
export const http2SettingError = (id: i32, value: i64): i32 => {
|
|
392
501
|
switch (id) {
|
|
@@ -407,7 +516,16 @@ export const http2SettingError = (id: i32, value: i64): i32 => {
|
|
|
407
516
|
/**
|
|
408
517
|
* Writes a frame header at `out[at]` for a payload of `length` bytes, and
|
|
409
518
|
* answers where the payload goes, or -1 when the header and the payload would
|
|
410
|
-
* not both fit.
|
|
519
|
+
* not both fit. It checks no type's rules: the payload is the caller's to write.
|
|
520
|
+
*
|
|
521
|
+
* @param out The buffer the frame is written into.
|
|
522
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
523
|
+
* @param length The payload's length in bytes, 0 to 2^24 − 1; outside that panics.
|
|
524
|
+
* @param type The frame type byte, an `H2_FRAME_*` or another 0 to 255; only its low 8 bits are written.
|
|
525
|
+
* @param flags The flags byte, unchecked; only its low 8 bits are written.
|
|
526
|
+
* @param streamId The stream identifier, 0 for the connection, to 2^31 − 1; a negative one panics.
|
|
527
|
+
* @returns `at + 9`, where the payload goes, or -1 when `out` has no room for the header and `length`
|
|
528
|
+
* bytes after it, `out` then unchanged.
|
|
411
529
|
*/
|
|
412
530
|
export const http2WriteHeader = (
|
|
413
531
|
out: u8[],
|
|
@@ -443,7 +561,7 @@ const http2FrameCopy = (out: u8[], at: i32, src: u8[], off: i32, len: i32): void
|
|
|
443
561
|
/**
|
|
444
562
|
* The shared shape of DATA, HEADERS, PUSH_PROMISE and CONTINUATION: the
|
|
445
563
|
* header, the Pad Length when `pad` is 0 to 255 (-1 for none), `fixed` bytes
|
|
446
|
-
* the caller fills
|
|
564
|
+
* the caller fills just before the content, the content and
|
|
447
565
|
* the padding. Answers the offset after the frame, or -1.
|
|
448
566
|
*/
|
|
449
567
|
const http2FrameWritePadded = (
|
|
@@ -485,7 +603,22 @@ const http2FrameWritePadded = (
|
|
|
485
603
|
return body + len + tail
|
|
486
604
|
}
|
|
487
605
|
|
|
488
|
-
/**
|
|
606
|
+
/**
|
|
607
|
+
* Writes a DATA frame of `src[off, off + len)` on `streamId`, with `flags` (END_STREAM) and `pad` bytes of
|
|
608
|
+
* padding, -1 for none (§6.1).
|
|
609
|
+
*
|
|
610
|
+
* @param out The buffer the frame is written into.
|
|
611
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
612
|
+
* @param streamId The stream the data belongs to, 1 to 2^31 − 1; 0 or a negative identifier panics.
|
|
613
|
+
* @param src The buffer holding the data; copied, not kept.
|
|
614
|
+
* @param off Where the data starts in `src`.
|
|
615
|
+
* @param len The data's length in bytes; `[off, off + len)` outside `src` panics, and so does a
|
|
616
|
+
* payload past 2^24 − 1 bytes. Keeping it within the peer's SETTINGS_MAX_FRAME_SIZE is the caller's.
|
|
617
|
+
* @param flags `H2_FLAG_END_STREAM` or 0; any other bit is dropped.
|
|
618
|
+
* @param pad Bytes of zero padding, 0 to 255, or -1 (any negative) for none; past 255 panics. PADDED is
|
|
619
|
+
* set from it, never from `flags`.
|
|
620
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
621
|
+
*/
|
|
489
622
|
export const http2WriteData = (
|
|
490
623
|
out: u8[],
|
|
491
624
|
at: i32,
|
|
@@ -518,6 +651,20 @@ export const http2WriteData = (
|
|
|
518
651
|
* len)` on `streamId`, with `flags` (END_STREAM, END_HEADERS) and `pad`
|
|
519
652
|
* bytes of padding, -1 for none (§6.2). It never sets PRIORITY, which RFC
|
|
520
653
|
* 9113 deprecates.
|
|
654
|
+
*
|
|
655
|
+
* @param out The buffer the frame is written into.
|
|
656
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
657
|
+
* @param streamId The stream the headers open or belong to, 1 to 2^31 − 1; 0 or a negative identifier
|
|
658
|
+
* panics.
|
|
659
|
+
* @param src The buffer holding the fragment; copied, not kept.
|
|
660
|
+
* @param off Where the fragment starts in `src`.
|
|
661
|
+
* @param len The fragment's length in bytes; `[off, off + len)` outside `src` panics, and so does a
|
|
662
|
+
* payload past 2^24 − 1 bytes. Keeping it within the peer's SETTINGS_MAX_FRAME_SIZE is the caller's.
|
|
663
|
+
* @param flags `H2_FLAG_END_STREAM` and `H2_FLAG_END_HEADERS`, either or both or neither; any other bit
|
|
664
|
+
* is dropped.
|
|
665
|
+
* @param pad Bytes of zero padding, 0 to 255, or -1 (any negative) for none; past 255 panics. PADDED is
|
|
666
|
+
* set from it, never from `flags`.
|
|
667
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
521
668
|
*/
|
|
522
669
|
export const http2WriteHeaders = (
|
|
523
670
|
out: u8[],
|
|
@@ -547,7 +694,18 @@ export const http2WriteHeaders = (
|
|
|
547
694
|
)
|
|
548
695
|
}
|
|
549
696
|
|
|
550
|
-
/**
|
|
697
|
+
/**
|
|
698
|
+
* Writes a PRIORITY frame: `streamId` depends on `dependency`, exclusively or not, with `weight` 1 to 256
|
|
699
|
+
* (§6.3).
|
|
700
|
+
*
|
|
701
|
+
* @param out The buffer the frame is written into.
|
|
702
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
703
|
+
* @param streamId The stream whose priority this sets, 1 to 2^31 − 1; 0 or a negative identifier panics.
|
|
704
|
+
* @param dependency The stream it depends on, 0 to 2^31 − 1; negative, or `streamId` itself, panics.
|
|
705
|
+
* @param exclusive Whether the dependency is exclusive (§5.3.1).
|
|
706
|
+
* @param weight The weight, 1 to 256, sent as one less; outside that panics.
|
|
707
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
708
|
+
*/
|
|
551
709
|
export const http2WritePriority = (
|
|
552
710
|
out: u8[],
|
|
553
711
|
at: i32,
|
|
@@ -569,7 +727,15 @@ export const http2WritePriority = (
|
|
|
569
727
|
return body + 5
|
|
570
728
|
}
|
|
571
729
|
|
|
572
|
-
/**
|
|
730
|
+
/**
|
|
731
|
+
* Writes a RST_STREAM frame closing `streamId` with `code` (§6.4).
|
|
732
|
+
*
|
|
733
|
+
* @param out The buffer the frame is written into.
|
|
734
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
735
|
+
* @param streamId The stream to close, 1 to 2^31 − 1; 0 or a negative identifier panics.
|
|
736
|
+
* @param code The error code, an `H2_*` of §7 or another 32-bit value; only its low 32 bits are sent.
|
|
737
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
738
|
+
*/
|
|
573
739
|
export const http2WriteRstStream = (out: u8[], at: i32, streamId: i32, code: i64): i32 => {
|
|
574
740
|
if (streamId === 0) {
|
|
575
741
|
panic("http2WriteRstStream: RST_STREAM on stream 0")
|
|
@@ -586,6 +752,12 @@ export const http2WriteRstStream = (out: u8[], at: i32, streamId: i32, code: i64
|
|
|
586
752
|
* Writes a SETTINGS frame of the settings `ids[k]` = `values[k]` (§6.5).
|
|
587
753
|
* A value `http2SettingError` refuses panics, as two lists of different
|
|
588
754
|
* lengths do.
|
|
755
|
+
*
|
|
756
|
+
* @param out The buffer the frame is written into.
|
|
757
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
758
|
+
* @param ids The settings' identifiers, each 0 to 65,535, in the order sent; read, not kept.
|
|
759
|
+
* @param values The settings' values, `values[k]` for `ids[k]`, each 0 to 2^32 − 1; read, not kept.
|
|
760
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
589
761
|
*/
|
|
590
762
|
export const http2WriteSettings = (out: u8[], at: i32, ids: i32[], values: i64[]): i32 => {
|
|
591
763
|
const n: i32 = toI32(ids.length)
|
|
@@ -625,7 +797,13 @@ export const http2WriteSettings = (out: u8[], at: i32, ids: i32[], values: i64[]
|
|
|
625
797
|
return body + n * H2_SETTING_SIZE
|
|
626
798
|
}
|
|
627
799
|
|
|
628
|
-
/**
|
|
800
|
+
/**
|
|
801
|
+
* Writes the empty SETTINGS frame with ACK that acknowledges the peer's (§6.5.3).
|
|
802
|
+
*
|
|
803
|
+
* @param out The buffer the frame is written into.
|
|
804
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
805
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
806
|
+
*/
|
|
629
807
|
export const http2WriteSettingsAck = (out: u8[], at: i32): i32 =>
|
|
630
808
|
http2WriteHeader(out, at, H2_FRAME_ZERO, H2_FRAME_SETTINGS, H2_FLAG_ACK, H2_FRAME_ZERO)
|
|
631
809
|
|
|
@@ -633,6 +811,20 @@ export const http2WriteSettingsAck = (out: u8[], at: i32): i32 =>
|
|
|
633
811
|
* Writes a PUSH_PROMISE frame on `streamId` reserving `promisedId`, carrying
|
|
634
812
|
* the header block fragment `src[off, off + len)`, with `flags`
|
|
635
813
|
* (END_HEADERS) and `pad` bytes of padding, -1 for none (§6.6).
|
|
814
|
+
*
|
|
815
|
+
* @param out The buffer the frame is written into.
|
|
816
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
817
|
+
* @param streamId The stream of the request the promise answers, 1 to 2^31 − 1; 0 or a negative
|
|
818
|
+
* identifier panics.
|
|
819
|
+
* @param promisedId The stream reserved for the push, 1 to 2^31 − 1; 0 or a negative identifier panics.
|
|
820
|
+
* @param src The buffer holding the fragment; copied, not kept.
|
|
821
|
+
* @param off Where the fragment starts in `src`.
|
|
822
|
+
* @param len The fragment's length in bytes; `[off, off + len)` outside `src` panics, and so does a
|
|
823
|
+
* payload past 2^24 − 1 bytes. Keeping it within the peer's SETTINGS_MAX_FRAME_SIZE is the caller's.
|
|
824
|
+
* @param flags `H2_FLAG_END_HEADERS` or 0; any other bit is dropped.
|
|
825
|
+
* @param pad Bytes of zero padding, 0 to 255, or -1 (any negative) for none; past 255 panics. PADDED is
|
|
826
|
+
* set from it, never from `flags`.
|
|
827
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
636
828
|
*/
|
|
637
829
|
export const http2WritePushPromise = (
|
|
638
830
|
out: u8[],
|
|
@@ -671,7 +863,16 @@ export const http2WritePushPromise = (
|
|
|
671
863
|
return end
|
|
672
864
|
}
|
|
673
865
|
|
|
674
|
-
/**
|
|
866
|
+
/**
|
|
867
|
+
* Writes a PING frame of the eight bytes `opaque[off, off + 8)`, an ACK when `ack` (§6.7).
|
|
868
|
+
*
|
|
869
|
+
* @param out The buffer the frame is written into.
|
|
870
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
871
|
+
* @param opaque The buffer holding the eight bytes; copied, not kept.
|
|
872
|
+
* @param off Where the eight bytes start in `opaque`; `[off, off + 8)` outside it panics.
|
|
873
|
+
* @param ack Whether this answers the peer's PING, its bytes echoed, rather than asking.
|
|
874
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
875
|
+
*/
|
|
675
876
|
export const http2WritePing = (out: u8[], at: i32, opaque: u8[], off: i32, ack: boolean): i32 => {
|
|
676
877
|
http2FrameCheckWindow("http2WritePing", opaque, off, 8)
|
|
677
878
|
const body: i32 = http2WriteHeader(out, at, 8, H2_FRAME_PING, ack ? H2_FLAG_ACK : 0, H2_FRAME_ZERO)
|
|
@@ -682,7 +883,21 @@ export const http2WritePing = (out: u8[], at: i32, opaque: u8[], off: i32, ack:
|
|
|
682
883
|
return body + 8
|
|
683
884
|
}
|
|
684
885
|
|
|
685
|
-
/**
|
|
886
|
+
/**
|
|
887
|
+
* Writes a GOAWAY frame naming `lastStreamId` and `code`, with the debug data `debug[off, off + len)`
|
|
888
|
+
* (§6.8).
|
|
889
|
+
*
|
|
890
|
+
* @param out The buffer the frame is written into.
|
|
891
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
892
|
+
* @param lastStreamId The highest peer-opened stream this side may have processed, 0 to 2^31 − 1; a
|
|
893
|
+
* negative one panics.
|
|
894
|
+
* @param code The error code, an `H2_*` of §7 or another 32-bit value; only its low 32 bits are sent.
|
|
895
|
+
* @param debug The buffer holding the debug data; copied, not kept.
|
|
896
|
+
* @param off Where the debug data starts in `debug`.
|
|
897
|
+
* @param len The debug data's length in bytes, 0 for none; `[off, off + len)` outside `debug` panics,
|
|
898
|
+
* and so does a payload past 2^24 − 1 bytes.
|
|
899
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
900
|
+
*/
|
|
686
901
|
export const http2WriteGoaway = (
|
|
687
902
|
out: u8[],
|
|
688
903
|
at: i32,
|
|
@@ -704,7 +919,16 @@ export const http2WriteGoaway = (
|
|
|
704
919
|
return body + 8 + len
|
|
705
920
|
}
|
|
706
921
|
|
|
707
|
-
/**
|
|
922
|
+
/**
|
|
923
|
+
* Writes a WINDOW_UPDATE frame adding `increment`, 1 to 2^31 − 1, to `streamId`'s window, or the
|
|
924
|
+
* connection's for 0 (§6.9).
|
|
925
|
+
*
|
|
926
|
+
* @param out The buffer the frame is written into.
|
|
927
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
928
|
+
* @param streamId The stream whose window widens, or 0 for the connection's; a negative one panics.
|
|
929
|
+
* @param increment The bytes added to the window, 1 to 2^31 − 1; below 1 panics.
|
|
930
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
931
|
+
*/
|
|
708
932
|
export const http2WriteWindowUpdate = (out: u8[], at: i32, streamId: i32, increment: i32): i32 => {
|
|
709
933
|
if (increment < 1) {
|
|
710
934
|
panic(`http2WriteWindowUpdate: an increment of ${increment}`)
|
|
@@ -717,7 +941,21 @@ export const http2WriteWindowUpdate = (out: u8[], at: i32, streamId: i32, increm
|
|
|
717
941
|
return body + 4
|
|
718
942
|
}
|
|
719
943
|
|
|
720
|
-
/**
|
|
944
|
+
/**
|
|
945
|
+
* Writes a CONTINUATION frame of the header block fragment `src[off, off + len)`, with `flags`
|
|
946
|
+
* (END_HEADERS) (§6.10). It is never padded.
|
|
947
|
+
*
|
|
948
|
+
* @param out The buffer the frame is written into.
|
|
949
|
+
* @param at Where the frame starts in `out`; a negative offset panics.
|
|
950
|
+
* @param streamId The stream whose header block this continues, 1 to 2^31 − 1; 0 or a negative
|
|
951
|
+
* identifier panics.
|
|
952
|
+
* @param src The buffer holding the fragment; copied, not kept.
|
|
953
|
+
* @param off Where the fragment starts in `src`.
|
|
954
|
+
* @param len The fragment's length in bytes; `[off, off + len)` outside `src` panics, and so does a
|
|
955
|
+
* payload past 2^24 − 1 bytes. Keeping it within the peer's SETTINGS_MAX_FRAME_SIZE is the caller's.
|
|
956
|
+
* @param flags `H2_FLAG_END_HEADERS` or 0; any other bit is dropped.
|
|
957
|
+
* @returns The offset just past the frame in `out`, or -1 when it would not fit, `out` then unchanged.
|
|
958
|
+
*/
|
|
721
959
|
export const http2WriteContinuation = (
|
|
722
960
|
out: u8[],
|
|
723
961
|
at: i32,
|