@browsercore/http1 0.1.3 → 0.1.9
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/README.md +43 -26
- package/dist/connection-helpers.d.ts +29 -0
- package/dist/connection-helpers.d.ts.map +1 -0
- package/dist/connection-helpers.js +144 -0
- package/dist/connection-helpers.js.map +1 -0
- package/dist/connection.d.ts +25 -19
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +114 -246
- package/dist/connection.js.map +1 -1
- package/dist/decompress.d.ts +2 -1
- package/dist/decompress.d.ts.map +1 -1
- package/dist/decompress.js +4 -2
- package/dist/decompress.js.map +1 -1
- package/dist/errors.d.ts +7 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -4
- package/dist/errors.js.map +1 -1
- package/dist/message.d.ts.map +1 -1
- package/dist/message.js +27 -52
- package/dist/message.js.map +1 -1
- package/dist/redirect.d.ts.map +1 -1
- package/dist/redirect.js +3 -2
- package/dist/redirect.js.map +1 -1
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +33 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +51 -0
- package/dist/utils.js.map +1 -1
- package/package.json +53 -48
package/dist/connection.js
CHANGED
|
@@ -6,111 +6,129 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { parseResponse, serializeRequest, parseChunkedEncoding } from "./message.js";
|
|
8
8
|
import { decompressBody } from "./decompress.js";
|
|
9
|
-
import { assertNever, createId } from "./utils.js";
|
|
9
|
+
import { assertNever, createId, createDeferred, decodeAscii } from "./utils.js";
|
|
10
|
+
import { collectSetCookie, describeCloseReason, extractContentLength, findChunkedBodyEnd, findHeaderEnd, isChunkedEncoding, materialize, chunkIterable, } from "./connection-helpers.js";
|
|
10
11
|
/** Concrete HTTP/1.1 connection. */
|
|
11
12
|
export class Http1ConnectionImpl {
|
|
12
|
-
|
|
13
|
+
options;
|
|
13
14
|
id;
|
|
14
15
|
state = { state: "idle" };
|
|
15
16
|
/**
|
|
16
17
|
* Incoming bytes not yet consumed by a parsed response. Drained by
|
|
17
18
|
* `bytesConsumed` after every parse — this is what makes keep-alive work.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
buffer = new Uint8Array(0);
|
|
20
21
|
/** Resolvers awaiting the next `data` event from the transport. */
|
|
21
|
-
|
|
22
|
+
dataWaiters = [];
|
|
22
23
|
/** Resolvers awaiting connection close (used by `close()` to drain in-flight). */
|
|
23
|
-
|
|
24
|
+
closeWaiters = [];
|
|
24
25
|
/** Set once the transport has closed unexpectedly (remote close / error). */
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
transportClosed = false;
|
|
27
|
+
/**
|
|
28
|
+
* Number of requests currently in flight. Held as a field rather than
|
|
29
|
+
* derived from `state` because `close()` transitions the discriminant to
|
|
30
|
+
* `"closing"` while requests are still pending — deriving the count from
|
|
31
|
+
* the discriminant would read 0 in that state and the final request's
|
|
32
|
+
* finally block would never wake the draining close waiter.
|
|
33
|
+
*/
|
|
34
|
+
pending = 0;
|
|
35
|
+
constructor(id, options) {
|
|
36
|
+
this.options = options;
|
|
28
37
|
this.id = id;
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
const waiter = this.
|
|
38
|
+
this.options.transport.on("data", (chunk) => {
|
|
39
|
+
this.appendBuffer(chunk);
|
|
40
|
+
const waiter = this.dataWaiters.shift();
|
|
32
41
|
if (waiter !== undefined) {
|
|
33
42
|
waiter(chunk);
|
|
34
43
|
}
|
|
35
44
|
});
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
45
|
+
this.options.transport.on("close", () => {
|
|
46
|
+
this.transportClosed = true;
|
|
38
47
|
// Wake any pending reads so they can observe the closed transport.
|
|
39
|
-
while (this.
|
|
40
|
-
const waiter = this.
|
|
41
|
-
if (waiter !== undefined)
|
|
48
|
+
while (this.dataWaiters.length > 0) {
|
|
49
|
+
const waiter = this.dataWaiters.shift();
|
|
50
|
+
if (waiter !== undefined) {
|
|
42
51
|
waiter(new Uint8Array(0));
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
});
|
|
45
55
|
}
|
|
46
56
|
async request(req) {
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
57
|
+
this.ensureOpen();
|
|
58
|
+
this.pending += 1;
|
|
59
|
+
this.transition({ state: "in_flight", pending: this.pending });
|
|
49
60
|
try {
|
|
50
61
|
// Cookie seam (optional): inject request cookies before serializing.
|
|
51
|
-
const interceptor = this.
|
|
62
|
+
const interceptor = this.options.cookieInterceptor;
|
|
52
63
|
let wireReq = req;
|
|
53
64
|
if (interceptor?.addCookies !== undefined) {
|
|
54
|
-
wireReq = this.
|
|
65
|
+
wireReq = this.injectCookies(req, interceptor.addCookies(this.cookieUrl(req)));
|
|
55
66
|
}
|
|
56
67
|
const wire = serializeRequest(wireReq);
|
|
57
|
-
await this.
|
|
58
|
-
const response = await this.
|
|
68
|
+
await this.options.transport.write(wire);
|
|
69
|
+
const response = await this.readResponse();
|
|
59
70
|
// Cookie seam (optional): collect response Set-Cookie headers.
|
|
60
71
|
if (interceptor?.storeCookies !== undefined) {
|
|
61
|
-
interceptor.storeCookies(this.
|
|
72
|
+
interceptor.storeCookies(this.cookieUrl(wireReq), collectSetCookie(response.headers));
|
|
62
73
|
}
|
|
63
74
|
return response;
|
|
64
75
|
}
|
|
65
76
|
finally {
|
|
66
|
-
|
|
67
|
-
if (pending === 0) {
|
|
68
|
-
this.
|
|
69
|
-
if (this.
|
|
70
|
-
for (const waiter of this.
|
|
77
|
+
this.pending -= 1;
|
|
78
|
+
if (this.pending === 0) {
|
|
79
|
+
this.transition({ state: "idle" });
|
|
80
|
+
if (this.closeWaiters.length > 0) {
|
|
81
|
+
for (const waiter of this.closeWaiters) {
|
|
71
82
|
waiter();
|
|
72
|
-
|
|
83
|
+
}
|
|
84
|
+
this.closeWaiters = [];
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
else {
|
|
76
|
-
this.
|
|
88
|
+
this.transition({ state: "in_flight", pending: this.pending });
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
91
|
}
|
|
80
92
|
async close(reason) {
|
|
81
93
|
const effectiveReason = reason ?? { kind: "client_close" };
|
|
82
|
-
if (this.
|
|
94
|
+
if (this.isClosedOrClosing()) {
|
|
83
95
|
return;
|
|
96
|
+
}
|
|
84
97
|
// If requests are in flight, wait for them to drain before closing.
|
|
85
|
-
if (this.
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
if (this.pending > 0) {
|
|
99
|
+
this.transition({ state: "closing" });
|
|
100
|
+
const deferred = createDeferred();
|
|
101
|
+
this.closeWaiters.push(deferred.resolve);
|
|
102
|
+
await deferred.promise;
|
|
90
103
|
}
|
|
91
|
-
if (this.
|
|
104
|
+
if (this.isClosedOrClosing()) {
|
|
92
105
|
return;
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
}
|
|
107
|
+
this.transition({ state: "closed", reason: effectiveReason });
|
|
108
|
+
await this.options.transport.close();
|
|
95
109
|
}
|
|
96
|
-
|
|
110
|
+
isClosedOrClosing() {
|
|
97
111
|
const s = this.state.state;
|
|
98
112
|
return s === "closed" || s === "closing";
|
|
99
113
|
}
|
|
100
114
|
/** Read bytes from the transport until a complete response is available. */
|
|
101
|
-
async
|
|
115
|
+
async readResponse() {
|
|
102
116
|
while (true) {
|
|
103
|
-
|
|
117
|
+
// Sequential parse over the accumulating buffer — each pass depends on the previous read.
|
|
118
|
+
// eslint-disable-next-line no-await-in-loop
|
|
119
|
+
const parsed = await this.tryParse();
|
|
104
120
|
if (parsed !== undefined) {
|
|
105
121
|
return parsed;
|
|
106
122
|
}
|
|
107
|
-
|
|
123
|
+
// Sequential streaming reads from the transport; order is load-bearing.
|
|
124
|
+
// eslint-disable-next-line no-await-in-loop
|
|
125
|
+
const chunk = await this.readChunk();
|
|
108
126
|
if (chunk === undefined) {
|
|
109
127
|
// Transport closed mid-response — drain what we have.
|
|
110
|
-
if (this.
|
|
111
|
-
const { response } = parseResponse(this.
|
|
112
|
-
this.
|
|
113
|
-
return this.
|
|
128
|
+
if (this.buffer.length > 0) {
|
|
129
|
+
const { response } = parseResponse(this.buffer);
|
|
130
|
+
this.buffer = this.buffer.slice(0, 0);
|
|
131
|
+
return this.decodeBody(response);
|
|
114
132
|
}
|
|
115
133
|
throw new Error("transport closed before response received");
|
|
116
134
|
}
|
|
@@ -123,30 +141,36 @@ export class Http1ConnectionImpl {
|
|
|
123
141
|
* Attempt to parse a complete response from the current buffer.
|
|
124
142
|
* Returns `undefined` if more bytes are needed.
|
|
125
143
|
*/
|
|
126
|
-
async
|
|
127
|
-
const headerEnd = findHeaderEnd(this.
|
|
128
|
-
if (headerEnd === -1)
|
|
144
|
+
async tryParse() {
|
|
145
|
+
const headerEnd = findHeaderEnd(this.buffer);
|
|
146
|
+
if (headerEnd === -1) {
|
|
129
147
|
return undefined;
|
|
148
|
+
}
|
|
130
149
|
const bodyStart = headerEnd + 4;
|
|
131
|
-
const headerText = decodeAscii(this.
|
|
150
|
+
const headerText = decodeAscii(this.buffer, 0, headerEnd);
|
|
132
151
|
const contentLength = extractContentLength(headerText);
|
|
133
152
|
const isChunked = isChunkedEncoding(headerText);
|
|
134
153
|
if (contentLength !== undefined) {
|
|
135
154
|
const totalLength = bodyStart + contentLength;
|
|
136
|
-
if (this.
|
|
155
|
+
if (this.buffer.length < totalLength) {
|
|
137
156
|
return undefined;
|
|
138
|
-
|
|
157
|
+
}
|
|
158
|
+
const parsed = await this.parseAndDrain(totalLength);
|
|
159
|
+
return parsed;
|
|
139
160
|
}
|
|
140
161
|
if (isChunked) {
|
|
141
|
-
const bodyEnd = findChunkedBodyEnd(this.
|
|
142
|
-
if (bodyEnd === -1)
|
|
162
|
+
const bodyEnd = findChunkedBodyEnd(this.buffer, bodyStart);
|
|
163
|
+
if (bodyEnd === -1) {
|
|
143
164
|
return undefined;
|
|
144
|
-
|
|
165
|
+
}
|
|
166
|
+
const parsed = await this.parseAndDrain(bodyEnd);
|
|
167
|
+
return parsed;
|
|
145
168
|
}
|
|
146
|
-
// No content-length and not chunked — body runs until transport
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
// No content-length and not chunked — the body runs until the transport
|
|
170
|
+
// closes, so its boundary can't be determined from headers alone. Return
|
|
171
|
+
// undefined and let `readResponse` observe the close (via `readChunk`
|
|
172
|
+
// resolving `undefined`) and drain whatever the buffer holds.
|
|
173
|
+
return undefined;
|
|
150
174
|
}
|
|
151
175
|
/**
|
|
152
176
|
* Parse the first `totalLength` bytes, drain them from the buffer, then
|
|
@@ -154,40 +178,34 @@ export class Http1ConnectionImpl {
|
|
|
154
178
|
* order: transfer-encoding first (it's the outer framing), then
|
|
155
179
|
* content-encoding on the reassembled bytes.
|
|
156
180
|
*/
|
|
157
|
-
|
|
158
|
-
const { response, bytesConsumed } = parseResponse(this.
|
|
159
|
-
this.
|
|
160
|
-
return this.
|
|
181
|
+
parseAndDrain(totalLength) {
|
|
182
|
+
const { response, bytesConsumed } = parseResponse(this.buffer.slice(0, totalLength));
|
|
183
|
+
this.buffer = this.buffer.slice(bytesConsumed);
|
|
184
|
+
return this.decodeBody(response);
|
|
161
185
|
}
|
|
162
186
|
/**
|
|
163
187
|
* Apply transfer-encoding (chunked) decoding then content-encoding
|
|
164
188
|
* decompression to a parsed response's body. `parseResponse` is kept pure
|
|
165
189
|
* (wire-format only); this is where protocol semantics get applied.
|
|
166
190
|
*/
|
|
167
|
-
async
|
|
168
|
-
const headers = response.headers;
|
|
191
|
+
async decodeBody(response) {
|
|
169
192
|
let body = response.body;
|
|
170
|
-
const isChunked = headers.get("transfer-encoding");
|
|
193
|
+
const isChunked = response.headers.get("transfer-encoding");
|
|
171
194
|
if (isChunked !== undefined && isChunked.toLowerCase().includes("chunked")) {
|
|
172
195
|
body = await materialize(parseChunkedEncoding(chunkIterable(body)));
|
|
173
196
|
}
|
|
174
|
-
const contentEncoding = headers.get("content-encoding");
|
|
197
|
+
const contentEncoding = response.headers.get("content-encoding");
|
|
175
198
|
if (contentEncoding !== undefined) {
|
|
176
199
|
body = decompressBody(body, contentEncoding);
|
|
177
200
|
}
|
|
178
|
-
return {
|
|
179
|
-
statusCode: response.statusCode,
|
|
180
|
-
statusText: response.statusText,
|
|
181
|
-
headers,
|
|
182
|
-
body,
|
|
183
|
-
};
|
|
201
|
+
return { ...response, body };
|
|
184
202
|
}
|
|
185
203
|
/** Read one chunk from the transport, or `undefined` once it has closed. */
|
|
186
|
-
|
|
204
|
+
readChunk() {
|
|
187
205
|
return new Promise((resolve) => {
|
|
188
|
-
this.
|
|
189
|
-
if (this.
|
|
190
|
-
resolve(
|
|
206
|
+
this.dataWaiters.push((chunk) => {
|
|
207
|
+
if (this.transportClosed && chunk.length === 0) {
|
|
208
|
+
resolve();
|
|
191
209
|
}
|
|
192
210
|
else {
|
|
193
211
|
resolve(chunk);
|
|
@@ -195,15 +213,16 @@ export class Http1ConnectionImpl {
|
|
|
195
213
|
});
|
|
196
214
|
});
|
|
197
215
|
}
|
|
198
|
-
|
|
199
|
-
if (chunk.length === 0)
|
|
216
|
+
appendBuffer(chunk) {
|
|
217
|
+
if (chunk.length === 0) {
|
|
200
218
|
return;
|
|
201
|
-
|
|
202
|
-
next
|
|
203
|
-
next.set(
|
|
204
|
-
this.
|
|
219
|
+
}
|
|
220
|
+
const next = new Uint8Array(this.buffer.length + chunk.length);
|
|
221
|
+
next.set(this.buffer, 0);
|
|
222
|
+
next.set(chunk, this.buffer.length);
|
|
223
|
+
this.buffer = next;
|
|
205
224
|
}
|
|
206
|
-
|
|
225
|
+
ensureOpen() {
|
|
207
226
|
const s = this.state;
|
|
208
227
|
switch (s.state) {
|
|
209
228
|
case "idle":
|
|
@@ -217,16 +236,9 @@ export class Http1ConnectionImpl {
|
|
|
217
236
|
assertNever(s);
|
|
218
237
|
}
|
|
219
238
|
}
|
|
220
|
-
|
|
239
|
+
transition(next) {
|
|
221
240
|
this.state = next;
|
|
222
241
|
}
|
|
223
|
-
/** Derive the current pending count from the state. */
|
|
224
|
-
_pendingCount() {
|
|
225
|
-
const s = this.state;
|
|
226
|
-
if (s.state === "in_flight")
|
|
227
|
-
return s.pending;
|
|
228
|
-
return 0;
|
|
229
|
-
}
|
|
230
242
|
/**
|
|
231
243
|
* Build the cookie-matching URL for a request.
|
|
232
244
|
*
|
|
@@ -236,7 +248,7 @@ export class Http1ConnectionImpl {
|
|
|
236
248
|
* (this stack is built for TLS). The seam is optional and only invoked when
|
|
237
249
|
* a caller supplies an interceptor.
|
|
238
250
|
*/
|
|
239
|
-
|
|
251
|
+
cookieUrl(req) {
|
|
240
252
|
const host = req.headers.get("host") ?? "";
|
|
241
253
|
return {
|
|
242
254
|
host: host.split(":")[0] ?? host,
|
|
@@ -248,16 +260,17 @@ export class Http1ConnectionImpl {
|
|
|
248
260
|
* Merge cookies returned by the interceptor into a request. A bare string
|
|
249
261
|
* is treated as the `Cookie` header value; a map is merged name->value.
|
|
250
262
|
*/
|
|
251
|
-
|
|
263
|
+
injectCookies(req, cookies) {
|
|
252
264
|
if (typeof cookies === "string") {
|
|
253
|
-
if (cookies === "")
|
|
265
|
+
if (cookies === "") {
|
|
254
266
|
return req;
|
|
255
|
-
|
|
256
|
-
headers.
|
|
267
|
+
}
|
|
268
|
+
const headers = new Map([...req.headers, ["cookie", cookies]]);
|
|
257
269
|
return { ...req, headers };
|
|
258
270
|
}
|
|
259
|
-
if (cookies.size === 0)
|
|
271
|
+
if (cookies.size === 0) {
|
|
260
272
|
return req;
|
|
273
|
+
}
|
|
261
274
|
const headers = new Map(req.headers);
|
|
262
275
|
for (const [name, value] of cookies) {
|
|
263
276
|
headers.set(name, value);
|
|
@@ -271,153 +284,8 @@ export class Http1ConnectionImpl {
|
|
|
271
284
|
* The transport is assumed to be already connected — this function only wraps
|
|
272
285
|
* it with the HTTP/1.1 protocol state machine.
|
|
273
286
|
*/
|
|
274
|
-
export
|
|
287
|
+
export function connectHttp1(options) {
|
|
275
288
|
const id = createId("http1");
|
|
276
|
-
return new Http1ConnectionImpl(id, options);
|
|
277
|
-
}
|
|
278
|
-
// --- Byte-level helpers --------------------------------------------------
|
|
279
|
-
/** Find the offset of the `\r\n\r\n` header terminator, or -1 if not present. */
|
|
280
|
-
function findHeaderEnd(buf) {
|
|
281
|
-
for (let i = 0; i + 3 < buf.length; i++) {
|
|
282
|
-
if (buf[i] === 0x0d &&
|
|
283
|
-
buf[i + 1] === 0x0a &&
|
|
284
|
-
buf[i + 2] === 0x0d &&
|
|
285
|
-
buf[i + 3] === 0x0a) {
|
|
286
|
-
return i;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return -1;
|
|
290
|
-
}
|
|
291
|
-
/** Decode a slice of bytes as ASCII without going through `Buffer`. */
|
|
292
|
-
function decodeAscii(buf, start, end) {
|
|
293
|
-
let out = "";
|
|
294
|
-
for (let i = start; i < end; i++) {
|
|
295
|
-
out += String.fromCharCode(buf[i]);
|
|
296
|
-
}
|
|
297
|
-
return out;
|
|
298
|
-
}
|
|
299
|
-
/** Extract the `content-length` header value, or `undefined` if absent. */
|
|
300
|
-
function extractContentLength(headerText) {
|
|
301
|
-
const match = /(?:^|\n)content-length:\s*(\d+)\r?/i.exec(headerText);
|
|
302
|
-
if (match === null)
|
|
303
|
-
return undefined;
|
|
304
|
-
const value = match[1];
|
|
305
|
-
return value === undefined ? undefined : Number(value);
|
|
306
|
-
}
|
|
307
|
-
/** Whether the response uses chunked transfer-encoding. */
|
|
308
|
-
function isChunkedEncoding(headerText) {
|
|
309
|
-
const match = /(?:^|\n)transfer-encoding:\s*([^\r\n]+)/i.exec(headerText);
|
|
310
|
-
if (match === null)
|
|
311
|
-
return false;
|
|
312
|
-
const value = match[1];
|
|
313
|
-
return value !== undefined && value.toLowerCase().includes("chunked");
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Find the offset just past the end of a chunked body in `buf`, starting the
|
|
317
|
-
* scan at `bodyStart`. Returns -1 if the terminating chunk has not arrived.
|
|
318
|
-
*/
|
|
319
|
-
function findChunkedBodyEnd(buf, bodyStart) {
|
|
320
|
-
let offset = bodyStart;
|
|
321
|
-
while (offset < buf.length) {
|
|
322
|
-
// Find the end of the chunk-size line.
|
|
323
|
-
let lineEnd = -1;
|
|
324
|
-
for (let i = offset; i + 1 < buf.length; i++) {
|
|
325
|
-
if (buf[i] === 0x0d && buf[i + 1] === 0x0a) {
|
|
326
|
-
lineEnd = i;
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (lineEnd === -1)
|
|
331
|
-
return -1;
|
|
332
|
-
const sizeLine = decodeAscii(buf, offset, lineEnd);
|
|
333
|
-
// exec returns null (not undefined) when there is no match.
|
|
334
|
-
if (!/^[0-9a-fA-F]+(?:;[^\r\n]*)?$/.test(sizeLine))
|
|
335
|
-
return -1;
|
|
336
|
-
const size = Number.parseInt(sizeLine, 16);
|
|
337
|
-
const dataStart = lineEnd + 2;
|
|
338
|
-
if (size === 0) {
|
|
339
|
-
// last-chunk = "1*("0") [ chunk-ext ] CRLF" — no chunk-data, no
|
|
340
|
-
// trailing data CRLF. dataStart points just past the "0\r\n".
|
|
341
|
-
// trailer-part follows: zero or more header-field lines, then a
|
|
342
|
-
// final blank line. consumeTrailers returns the offset just past
|
|
343
|
-
// that final blank line, or -1 if the buffer doesn't hold it all.
|
|
344
|
-
const trailerEnd = consumeTrailers(buf, dataStart);
|
|
345
|
-
return trailerEnd === -1 ? -1 : trailerEnd;
|
|
346
|
-
}
|
|
347
|
-
const dataEnd = dataStart + size;
|
|
348
|
-
const chunkEnd = dataEnd + 2; // trailing \r\n after chunk data
|
|
349
|
-
if (chunkEnd > buf.length)
|
|
350
|
-
return -1;
|
|
351
|
-
if (buf[dataEnd] !== 0x0d || buf[dataEnd + 1] !== 0x0a)
|
|
352
|
-
return -1;
|
|
353
|
-
offset = chunkEnd;
|
|
354
|
-
}
|
|
355
|
-
return -1;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Consume the trailer section (zero or more header-field lines + a final blank
|
|
359
|
-
* line) starting at `start`. Returns the offset just past the terminating blank
|
|
360
|
-
* line, or -1 if the buffer does not yet hold the full trailer section.
|
|
361
|
-
*
|
|
362
|
-
* A blank line is a `CRLF` at `lineStart` — i.e. two consecutive CRLFs with no
|
|
363
|
-
* header content between them. This mirrors the trailer handling in
|
|
364
|
-
* `parseChunkedEncoding`.
|
|
365
|
-
*/
|
|
366
|
-
function consumeTrailers(buf, start) {
|
|
367
|
-
let lineStart = start;
|
|
368
|
-
for (let i = start; i + 1 < buf.length; i++) {
|
|
369
|
-
if (buf[i] !== 0x0d || buf[i + 1] !== 0x0a)
|
|
370
|
-
continue;
|
|
371
|
-
if (i === lineStart)
|
|
372
|
-
return i + 2; // blank line — end of trailers
|
|
373
|
-
lineStart = i + 2;
|
|
374
|
-
}
|
|
375
|
-
return -1;
|
|
376
|
-
}
|
|
377
|
-
/** Human-readable description of a close reason — for error messages. */
|
|
378
|
-
function describeCloseReason(reason) {
|
|
379
|
-
switch (reason.kind) {
|
|
380
|
-
case "client_close":
|
|
381
|
-
return "client closed";
|
|
382
|
-
case "remote_close":
|
|
383
|
-
return "remote closed";
|
|
384
|
-
case "error":
|
|
385
|
-
return `error: ${reason.error.message}`;
|
|
386
|
-
case "redirect_jump":
|
|
387
|
-
return `redirect to ${reason.to}`;
|
|
388
|
-
default:
|
|
389
|
-
assertNever(reason);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
// --- Body decoding helpers -----------------------------------------------
|
|
393
|
-
/** Yield the bytes of a single buffer as an `AsyncIterable` (one chunk). */
|
|
394
|
-
async function* chunkIterable(buf) {
|
|
395
|
-
if (buf.length > 0)
|
|
396
|
-
yield buf;
|
|
397
|
-
}
|
|
398
|
-
/** Collect all chunks of an async byte stream into one contiguous buffer. */
|
|
399
|
-
async function materialize(stream) {
|
|
400
|
-
const chunks = [];
|
|
401
|
-
let total = 0;
|
|
402
|
-
for await (const chunk of stream) {
|
|
403
|
-
chunks.push(chunk);
|
|
404
|
-
total += chunk.length;
|
|
405
|
-
}
|
|
406
|
-
const out = new Uint8Array(total);
|
|
407
|
-
let offset = 0;
|
|
408
|
-
for (const chunk of chunks) {
|
|
409
|
-
out.set(chunk, offset);
|
|
410
|
-
offset += chunk.length;
|
|
411
|
-
}
|
|
412
|
-
return out;
|
|
413
|
-
}
|
|
414
|
-
/** Collect all `set-cookie` header values (case-insensitive) in wire order. */
|
|
415
|
-
function collectSetCookie(headers) {
|
|
416
|
-
const out = [];
|
|
417
|
-
for (const [name, value] of headers) {
|
|
418
|
-
if (name === "set-cookie")
|
|
419
|
-
out.push(value);
|
|
420
|
-
}
|
|
421
|
-
return out;
|
|
289
|
+
return Promise.resolve(new Http1ConnectionImpl(id, options));
|
|
422
290
|
}
|
|
423
291
|
//# sourceMappingURL=connection.js.map
|
package/dist/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD,oCAAoC;AACpC,MAAM,OAAO,mBAAmB;IAqBP;IApBL,EAAE,CAAoB;IAC/B,KAAK,GAAyB,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAEvD;;;OAGG;IACK,OAAO,GAAe,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAEhD,mEAAmE;IAC3D,YAAY,GAAsC,EAAE,CAAC;IAE7D,kFAAkF;IAC1E,aAAa,GAAsB,EAAE,CAAC;IAE9C,6EAA6E;IACrE,gBAAgB,GA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;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqB;IAC9C,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,mBAAmB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/decompress.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Kept out of `message.ts` so the message parser stays a pure wire-format
|
|
10
10
|
* function with no dependency on zlib.
|
|
11
11
|
*/
|
|
12
|
+
import { type CompressionProvider } from "@browsercore/compression";
|
|
12
13
|
/** Content-encoding values we can decode — literal union, never bare `string`. */
|
|
13
14
|
export type ContentEncoding = "gzip" | "deflate" | "br";
|
|
14
15
|
/** Whether `value` is a content-encoding we know how to decode. */
|
|
@@ -23,5 +24,5 @@ export declare function isSupportedContentEncoding(value: string): value is Cont
|
|
|
23
24
|
*
|
|
24
25
|
* @throws {ContentEncodingError} on an unsupported value or corrupt stream.
|
|
25
26
|
*/
|
|
26
|
-
export declare function decompressBody(body: Uint8Array, encoding: string): Uint8Array;
|
|
27
|
+
export declare function decompressBody(body: Uint8Array, encoding: string, provider?: CompressionProvider): Uint8Array;
|
|
27
28
|
//# sourceMappingURL=decompress.d.ts.map
|
package/dist/decompress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGH,KAAK,mBAAmB,EAE3B,MAAM,0BAA0B,CAAC;AAGlC,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAIxD,mEAAmE;AACnE,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAElF;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC1B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,mBAAiC,GAC5C,UAAU,CAgBZ"}
|
package/dist/decompress.js
CHANGED
|
@@ -26,9 +26,9 @@ export function isSupportedContentEncoding(value) {
|
|
|
26
26
|
*
|
|
27
27
|
* @throws {ContentEncodingError} on an unsupported value or corrupt stream.
|
|
28
28
|
*/
|
|
29
|
-
export function decompressBody(body, encoding) {
|
|
29
|
+
export function decompressBody(body, encoding, provider = compression) {
|
|
30
30
|
try {
|
|
31
|
-
return
|
|
31
|
+
return provider.decompress(body, encoding);
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
34
34
|
// The provider throws its own typed errors; re-wrap as http1's
|
|
@@ -39,6 +39,8 @@ export function decompressBody(body, encoding) {
|
|
|
39
39
|
if (err instanceof DecompressionError) {
|
|
40
40
|
throw new ContentEncodingError(err.encoding, { cause: err });
|
|
41
41
|
}
|
|
42
|
+
// Anything else is unexpected from a well-behaved provider — let it
|
|
43
|
+
// propagate rather than swallowing it behind a ContentEncodingError.
|
|
42
44
|
throw err;
|
|
43
45
|
}
|
|
44
46
|
}
|
package/dist/decompress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompress.js","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,WAAW,EACX,kBAAkB,
|
|
1
|
+
{"version":3,"file":"decompress.js","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,WAAW,EACX,kBAAkB,EAElB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKnD,MAAM,mBAAmB,GAA+B,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAElF,mEAAmE;AACnE,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACpD,OAAQ,mBAAyC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC1B,IAAgB,EAChB,QAAgB,EAChB,QAAQ,GAAwB,WAAW;IAE3C,IAAI,CAAC;QACD,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,+DAA+D;QAC/D,oEAAoE;QACpE,IAAI,GAAG,YAAY,wBAAwB,EAAE,CAAC;YAC1C,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;YACpC,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,oEAAoE;QACpE,qEAAqE;QACrE,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* Errors are part of the API — every failure mode is an explicit type so callers
|
|
5
5
|
* can match on `kind` instead of parsing messages.
|
|
6
6
|
*/
|
|
7
|
+
/** Discriminated union of all HTTP/1.1 error kinds. */
|
|
8
|
+
export type Http1ErrorKind = "Http1Error" | "RedirectLimitError" | "InvalidResponseError" | "ContentEncodingError" | "ChunkEncodingError";
|
|
7
9
|
/** Base class for all HTTP/1.1 errors. */
|
|
8
10
|
export declare class Http1Error extends Error {
|
|
9
|
-
readonly kind:
|
|
11
|
+
readonly kind: Http1ErrorKind;
|
|
10
12
|
readonly cause: Error | undefined;
|
|
11
13
|
constructor(message: string, options?: {
|
|
12
14
|
cause?: Error;
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
/** Redirect chain exceeded {@link Http1Options.maxRedirects}. */
|
|
16
|
-
export declare class RedirectLimitError extends
|
|
18
|
+
export declare class RedirectLimitError extends Http1Error {
|
|
17
19
|
readonly kind: "RedirectLimitError";
|
|
18
20
|
readonly limit: number;
|
|
19
21
|
/** The URLs visited so far, in order — useful for debugging redirect loops. */
|
|
@@ -24,7 +26,7 @@ export declare class RedirectLimitError extends Error {
|
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
/** The remote sent bytes that could not be parsed as a valid HTTP/1.1 response. */
|
|
27
|
-
export declare class InvalidResponseError extends
|
|
29
|
+
export declare class InvalidResponseError extends Http1Error {
|
|
28
30
|
readonly kind: "InvalidResponseError";
|
|
29
31
|
/** The raw bytes that failed to parse — truncated to a sane length for logging. */
|
|
30
32
|
readonly rawPreview: string;
|
|
@@ -34,7 +36,7 @@ export declare class InvalidResponseError extends Error {
|
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
/** The response used a `content-encoding` this client cannot decode. */
|
|
37
|
-
export declare class ContentEncodingError extends
|
|
39
|
+
export declare class ContentEncodingError extends Http1Error {
|
|
38
40
|
readonly kind: "ContentEncodingError";
|
|
39
41
|
/** The unsupported (or corrupt) content-encoding token. */
|
|
40
42
|
readonly encoding: string;
|
|
@@ -44,7 +46,7 @@ export declare class ContentEncodingError extends Error {
|
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
/** A chunked transfer-encoding body was malformed. */
|
|
47
|
-
export declare class ChunkEncodingError extends
|
|
49
|
+
export declare class ChunkEncodingError extends Http1Error {
|
|
48
50
|
readonly kind: "ChunkEncodingError";
|
|
49
51
|
/** Byte offset in the body stream where the malformed chunk was detected. */
|
|
50
52
|
readonly offset: number;
|