@browsercore/http1 0.2.0 → 0.2.2
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 +38 -2
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +24 -7
- package/dist/connection.js.map +1 -1
- package/dist/decompress.d.ts +27 -9
- package/dist/decompress.d.ts.map +1 -1
- package/dist/decompress.js +17 -20
- package/dist/decompress.js.map +1 -1
- package/dist/errors.d.ts +25 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/message.d.ts +17 -1
- package/dist/message.d.ts.map +1 -1
- package/dist/message.js +31 -4
- package/dist/message.js.map +1 -1
- package/dist/types.d.ts +57 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +18 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -4
- package/dist/utils.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @browsercore/http1
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@browsercore/http1)
|
|
4
|
-
[](https://github.com/jverneuer/browsercore-http1/blob/main/COVERAGE.md)
|
|
5
5
|
[](https://github.com/jverneuer/browsercore-http1/actions/workflows/ci.yml)
|
|
6
6
|
|
|
7
7
|
An HTTP/1.1 client over any duplex byte stream. Serializes requests, parses
|
|
@@ -72,7 +72,43 @@ try {
|
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
`@browsercore/compression` wraps `node:zlib`; `@browsercore/http1` calls it
|
|
75
|
-
never `node:zlib` directly.
|
|
75
|
+
never `node:zlib` directly. `@browsercore/http1` does NOT import `node:events`
|
|
76
|
+
— event emission is composed exclusively through the injected `EventProvider`
|
|
77
|
+
on the `Transport` it consumes (browsersmith is the composition root that
|
|
78
|
+
provides the runtime backend).
|
|
79
|
+
|
|
80
|
+
## Platform threading
|
|
81
|
+
|
|
82
|
+
`Http1Options` accepts an optional `platform?: Platform` field. When supplied,
|
|
83
|
+
any service not passed as an individual field is resolved from the Platform
|
|
84
|
+
composition root:
|
|
85
|
+
|
|
86
|
+
| Option field | Resolved from |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `decompressionProvider` | `platform.compression` |
|
|
89
|
+
| `clock` | `platform.time.clock` |
|
|
90
|
+
|
|
91
|
+
Individual fields always take precedence, so existing callers that pass
|
|
92
|
+
`decompressionProvider`/`clock` directly keep working unchanged. This is the
|
|
93
|
+
migration path toward DI through Platform: callers move from passing individual
|
|
94
|
+
service fields to threading a single Platform (assembled by `browsersmith`) through
|
|
95
|
+
every protocol package. See `@browsercore/contracts` for the `Platform` interface.
|
|
96
|
+
|
|
97
|
+
## Position in BrowserCore
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Application
|
|
101
|
+
│
|
|
102
|
+
@browsercore/http1
|
|
103
|
+
│
|
|
104
|
+
@browsercore/tls
|
|
105
|
+
│
|
|
106
|
+
@browsercore/transport
|
|
107
|
+
│
|
|
108
|
+
TCP
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Every higher networking layer communicates with the network exclusively through the layers below it.
|
|
76
112
|
|
|
77
113
|
## License
|
|
78
114
|
|
package/dist/connection.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Wires the message parser/serializer over a `@browsercore/transport` duplex byte
|
|
5
5
|
* stream. Handles keep-alive via serial request/response on a single connection.
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
7
|
+
import { type Http1CloseReason, type Http1Connection, type Http1ConnectionId, type Http1ConnectionState, type Http1Options, type HttpRequest, type HttpResponse } from "./types.js";
|
|
8
8
|
/** Concrete HTTP/1.1 connection. */
|
|
9
9
|
export declare class Http1ConnectionImpl implements Http1Connection {
|
|
10
10
|
private readonly options;
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEH,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAEpB,MAAM,YAAY,CAAC;AAoBpB,oCAAoC;AACpC,qBAAa,mBAAoB,YAAW,eAAe;IA8BnD,OAAO,CAAC,QAAQ,CAAC,OAAO;IA7B5B,SAAgB,EAAE,EAAE,iBAAiB,CAAC;IAC/B,KAAK,EAAE,oBAAoB,CAAqB;IAEvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAiC;IAE/C,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAyC;IAE5D,kFAAkF;IAClF,OAAO,CAAC,YAAY,CAAyB;IAE7C,6EAA6E;IAC7E,OAAO,CAAC,eAAe,CAAS;IAEhC;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,CAAK;IAEpB,YACI,EAAE,EAAE,iBAAiB,EACJ,OAAO,EAAE,YAAY,EAwBzC;IAEY,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAmC5D;IAEY,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB3D;IAED,OAAO,CAAC,iBAAiB;IAKzB,4EAA4E;YAC9D,YAAY;IA0B1B;;;OAGG;YACW,QAAQ;IAqCtB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;YACW,UAAU;IAuBxB,4EAA4E;IAC5E,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,UAAU;IAIlB;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;IASjB;;;OAGG;IACH,OAAO,CAAC,aAAa;CAoBxB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAI5E"}
|
package/dist/connection.js
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* Wires the message parser/serializer over a `@browsercore/transport` duplex byte
|
|
5
5
|
* stream. Handles keep-alive via serial request/response on a single connection.
|
|
6
6
|
*/
|
|
7
|
+
import { systemClock, } from "./types.js";
|
|
7
8
|
import { parseResponse, serializeRequest, parseChunkedEncoding } from "./message.js";
|
|
8
9
|
import { decompressBody } from "./decompress.js";
|
|
9
|
-
import { assertNever, createId, createDeferred, decodeAscii } from "./utils.js";
|
|
10
|
+
import { assertNever, createId, createDeferred, decodeAscii, nodeRandomSource } from "./utils.js";
|
|
11
|
+
import { ConnectionClosedError, ConnectionClosingError, ContentEncodingError, } from "./errors.js";
|
|
10
12
|
import { collectSetCookie, describeCloseReason, extractContentLength, findChunkedBodyEnd, findHeaderEnd, isChunkedEncoding, materialize, chunkIterable, } from "./connection-helpers.js";
|
|
11
13
|
/** Concrete HTTP/1.1 connection. */
|
|
12
14
|
export class Http1ConnectionImpl {
|
|
@@ -35,7 +37,11 @@ export class Http1ConnectionImpl {
|
|
|
35
37
|
constructor(id, options) {
|
|
36
38
|
this.options = options;
|
|
37
39
|
this.id = id;
|
|
38
|
-
|
|
40
|
+
// The transport's EventProvider surface is string-event typed
|
|
41
|
+
// (`(...args: unknown[]) => void`); the "data" event always carries a
|
|
42
|
+
// single Uint8Array payload, narrowed here at the boundary.
|
|
43
|
+
this.options.transport.on("data", (...args) => {
|
|
44
|
+
const chunk = args[0];
|
|
39
45
|
this.appendBuffer(chunk);
|
|
40
46
|
const waiter = this.dataWaiters.shift();
|
|
41
47
|
if (waiter !== undefined) {
|
|
@@ -130,7 +136,7 @@ export class Http1ConnectionImpl {
|
|
|
130
136
|
this.buffer = this.buffer.slice(0, 0);
|
|
131
137
|
return this.decodeBody(response);
|
|
132
138
|
}
|
|
133
|
-
throw new
|
|
139
|
+
throw new ConnectionClosedError();
|
|
134
140
|
}
|
|
135
141
|
// The chunk was already appended to the buffer by the "data" event
|
|
136
142
|
// handler, which also woke this waiter. Nothing more to do here.
|
|
@@ -196,7 +202,14 @@ export class Http1ConnectionImpl {
|
|
|
196
202
|
}
|
|
197
203
|
const contentEncoding = response.headers.get("content-encoding");
|
|
198
204
|
if (contentEncoding !== undefined) {
|
|
199
|
-
|
|
205
|
+
const provider = this.options.decompressionProvider;
|
|
206
|
+
if (provider === undefined) {
|
|
207
|
+
// No backend was injected — we cannot safely decode. Raising
|
|
208
|
+
// here keeps the "no corrupt bytes" invariant instead of
|
|
209
|
+
// returning the compressed body as-is.
|
|
210
|
+
throw new ContentEncodingError(contentEncoding);
|
|
211
|
+
}
|
|
212
|
+
body = decompressBody(body, contentEncoding, provider);
|
|
200
213
|
}
|
|
201
214
|
return { ...response, body };
|
|
202
215
|
}
|
|
@@ -205,7 +218,10 @@ export class Http1ConnectionImpl {
|
|
|
205
218
|
return new Promise((resolve) => {
|
|
206
219
|
this.dataWaiters.push((chunk) => {
|
|
207
220
|
if (this.transportClosed && chunk.length === 0) {
|
|
208
|
-
|
|
221
|
+
// Resolver param is `(value: Uint8Array | undefined) => void`
|
|
222
|
+
// (non-optional), so `undefined` must be passed explicitly.
|
|
223
|
+
// oxlint-disable-next-line unicorn/no-useless-undefined
|
|
224
|
+
resolve(undefined);
|
|
209
225
|
}
|
|
210
226
|
else {
|
|
211
227
|
resolve(chunk);
|
|
@@ -229,7 +245,7 @@ export class Http1ConnectionImpl {
|
|
|
229
245
|
case "in_flight":
|
|
230
246
|
return;
|
|
231
247
|
case "closing":
|
|
232
|
-
throw new
|
|
248
|
+
throw new ConnectionClosingError();
|
|
233
249
|
case "closed":
|
|
234
250
|
throw new Error(`connection is closed: ${describeCloseReason(s.reason)}`);
|
|
235
251
|
default:
|
|
@@ -285,7 +301,8 @@ export class Http1ConnectionImpl {
|
|
|
285
301
|
* it with the HTTP/1.1 protocol state machine.
|
|
286
302
|
*/
|
|
287
303
|
export function connectHttp1(options) {
|
|
288
|
-
const
|
|
304
|
+
const random = options.random ?? nodeRandomSource;
|
|
305
|
+
const id = createId("http1", random, options.clock ?? systemClock);
|
|
289
306
|
return Promise.resolve(new Http1ConnectionImpl(id, options));
|
|
290
307
|
}
|
|
291
308
|
//# 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;
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EASH,WAAW,GACd,MAAM,YAAY,CAAC;AACpB,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,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EACH,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,aAAa,GAChB,MAAM,yBAAyB,CAAC;AAEjC,oCAAoC;AACpC,MAAM,OAAO,m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|
* Pure function — operates on the full buffered body bytes (after any
|
|
5
|
-
* transfer-encoding has been removed).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* transfer-encoding has been removed). http1 does NOT own a zlib backend — a
|
|
6
|
+
* {@link DecompressionProvider} is injected by the caller (typically
|
|
7
|
+
* @browsercore/fetch) so this package never imports @browsercore/compression
|
|
8
|
+
* directly (that was a layering violation: http1 composes over @browsercore/*
|
|
9
|
+
* packages *below* it; compression is a sibling, reached only via fetch).
|
|
10
|
+
* Any failure to decompress is mapped onto HTTP/1.1's
|
|
11
|
+
* {@link ContentEncodingError} — the original provider error is preserved as
|
|
12
|
+
* `cause` so nothing is hidden.
|
|
8
13
|
*
|
|
9
14
|
* Kept out of `message.ts` so the message parser stays a pure wire-format
|
|
10
15
|
* function with no dependency on zlib.
|
|
11
16
|
*/
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The decompression backend seam.
|
|
19
|
+
*
|
|
20
|
+
* http1 depends only on this interface, never on a concrete zlib provider.
|
|
21
|
+
* The caller (typically @browsercore/fetch) injects an implementation —
|
|
22
|
+
* the platform's compression adapter (composed in browsersmith). `decompress`
|
|
23
|
+
* full body bytes and the `content-encoding` header value and must return the
|
|
24
|
+
* decoded bytes; it may throw on an unsupported or corrupt stream (http1 wraps
|
|
25
|
+
* any thrown error as a {@link ContentEncodingError}).
|
|
26
|
+
*/
|
|
27
|
+
export interface DecompressionProvider {
|
|
28
|
+
/** Decompress a body according to a `content-encoding` header value. */
|
|
29
|
+
decompress(data: Uint8Array, encoding: string): Uint8Array;
|
|
30
|
+
}
|
|
13
31
|
/** Content-encoding values we can decode — literal union, never bare `string`. */
|
|
14
32
|
export type ContentEncoding = "gzip" | "deflate" | "br";
|
|
15
33
|
/** Whether `value` is a content-encoding we know how to decode. */
|
|
@@ -18,11 +36,11 @@ export declare function isSupportedContentEncoding(value: string): value is Cont
|
|
|
18
36
|
* Decompress a body according to a `content-encoding` header value.
|
|
19
37
|
*
|
|
20
38
|
* For `deflate`, servers disagree on framing: some send a zlib-wrapped stream
|
|
21
|
-
* (what the RFC calls for), some send raw deflate. The
|
|
22
|
-
*
|
|
23
|
-
* browser tolerance.
|
|
39
|
+
* (what the RFC calls for), some send raw deflate. The injected provider is
|
|
40
|
+
* expected to mirror browser tolerance (try zlib first, fall back to raw).
|
|
24
41
|
*
|
|
25
|
-
* @throws {ContentEncodingError} on
|
|
42
|
+
* @throws {ContentEncodingError} on any decompression failure — the original
|
|
43
|
+
* provider error is attached as `cause`.
|
|
26
44
|
*/
|
|
27
|
-
export declare function decompressBody(body: Uint8Array, encoding: string, provider
|
|
45
|
+
export declare function decompressBody(body: Uint8Array, encoding: string, provider: DecompressionProvider): Uint8Array;
|
|
28
46
|
//# 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
|
|
1
|
+
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IAClC,wEAAwE;IACxE,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9D;AAED,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,EAAE,qBAAqB,GAChC,UAAU,CASZ"}
|
package/dist/decompress.js
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* Content-encoding decompression for HTTP/1.1 responses.
|
|
3
3
|
*
|
|
4
4
|
* Pure function — operates on the full buffered body bytes (after any
|
|
5
|
-
* transfer-encoding has been removed).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* transfer-encoding has been removed). http1 does NOT own a zlib backend — a
|
|
6
|
+
* {@link DecompressionProvider} is injected by the caller (typically
|
|
7
|
+
* @browsercore/fetch) so this package never imports @browsercore/compression
|
|
8
|
+
* directly (that was a layering violation: http1 composes over @browsercore/*
|
|
9
|
+
* packages *below* it; compression is a sibling, reached only via fetch).
|
|
10
|
+
* Any failure to decompress is mapped onto HTTP/1.1's
|
|
11
|
+
* {@link ContentEncodingError} — the original provider error is preserved as
|
|
12
|
+
* `cause` so nothing is hidden.
|
|
8
13
|
*
|
|
9
14
|
* Kept out of `message.ts` so the message parser stays a pure wire-format
|
|
10
15
|
* function with no dependency on zlib.
|
|
11
16
|
*/
|
|
12
|
-
import { compression, DecompressionError, UnsupportedEncodingError, } from "@browsercore/compression";
|
|
13
17
|
import { ContentEncodingError } from "./errors.js";
|
|
14
18
|
const SUPPORTED_ENCODINGS = ["gzip", "deflate", "br"];
|
|
15
19
|
/** Whether `value` is a content-encoding we know how to decode. */
|
|
@@ -20,28 +24,21 @@ export function isSupportedContentEncoding(value) {
|
|
|
20
24
|
* Decompress a body according to a `content-encoding` header value.
|
|
21
25
|
*
|
|
22
26
|
* For `deflate`, servers disagree on framing: some send a zlib-wrapped stream
|
|
23
|
-
* (what the RFC calls for), some send raw deflate. The
|
|
24
|
-
*
|
|
25
|
-
* browser tolerance.
|
|
27
|
+
* (what the RFC calls for), some send raw deflate. The injected provider is
|
|
28
|
+
* expected to mirror browser tolerance (try zlib first, fall back to raw).
|
|
26
29
|
*
|
|
27
|
-
* @throws {ContentEncodingError} on
|
|
30
|
+
* @throws {ContentEncodingError} on any decompression failure — the original
|
|
31
|
+
* provider error is attached as `cause`.
|
|
28
32
|
*/
|
|
29
|
-
export function decompressBody(body, encoding, provider
|
|
33
|
+
export function decompressBody(body, encoding, provider) {
|
|
30
34
|
try {
|
|
31
35
|
return provider.decompress(body, encoding);
|
|
32
36
|
}
|
|
33
37
|
catch (err) {
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (err instanceof DecompressionError) {
|
|
40
|
-
throw new ContentEncodingError(err.encoding, { cause: err });
|
|
41
|
-
}
|
|
42
|
-
// Anything else is unexpected from a well-behaved provider — let it
|
|
43
|
-
// propagate rather than swallowing it behind a ContentEncodingError.
|
|
44
|
-
throw err;
|
|
38
|
+
// Normalize non-Error throws (a provider may throw anything) into an
|
|
39
|
+
// Error before attaching as cause, so the contract holds either way.
|
|
40
|
+
const cause = err instanceof Error ? err : new Error(String(err));
|
|
41
|
+
throw new ContentEncodingError(encoding, { cause });
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
//# sourceMappingURL=decompress.js.map
|
package/dist/decompress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompress.js","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"decompress.js","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAoBnD,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,QAA+B;IAE/B,IAAI,CAAC;QACD,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,qEAAqE;QACrE,qEAAqE;QACrE,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,MAAM,IAAI,oBAAoB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;AACL,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* can match on `kind` instead of parsing messages.
|
|
6
6
|
*/
|
|
7
7
|
/** Discriminated union of all HTTP/1.1 error kinds. */
|
|
8
|
-
export type Http1ErrorKind = "Http1Error" | "RedirectLimitError" | "InvalidResponseError" | "ContentEncodingError" | "ChunkEncodingError";
|
|
8
|
+
export type Http1ErrorKind = "Http1Error" | "RedirectLimitError" | "InvalidResponseError" | "ContentEncodingError" | "ChunkEncodingError" | "ConnectionClosedError" | "ConnectionClosingError" | "DecodeError";
|
|
9
9
|
/** Base class for all HTTP/1.1 errors. */
|
|
10
10
|
export declare class Http1Error extends Error {
|
|
11
11
|
readonly kind: Http1ErrorKind;
|
|
@@ -55,4 +55,28 @@ export declare class ChunkEncodingError extends Http1Error {
|
|
|
55
55
|
cause?: Error;
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
+
/** The transport closed before a complete response was received. */
|
|
59
|
+
export declare class ConnectionClosedError extends Http1Error {
|
|
60
|
+
readonly kind: "ConnectionClosedError";
|
|
61
|
+
constructor(options?: {
|
|
62
|
+
cause?: Error;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** A new request was attempted on a connection that is closing. */
|
|
66
|
+
export declare class ConnectionClosingError extends Http1Error {
|
|
67
|
+
readonly kind: "ConnectionClosingError";
|
|
68
|
+
constructor(options?: {
|
|
69
|
+
cause?: Error;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** A slice of bytes could not be decoded as ASCII. */
|
|
73
|
+
export declare class DecodeError extends Http1Error {
|
|
74
|
+
readonly kind: "DecodeError";
|
|
75
|
+
/** The index in the buffer that was out of bounds. */
|
|
76
|
+
readonly index: number;
|
|
77
|
+
readonly cause: Error | undefined;
|
|
78
|
+
constructor(index: number, options?: {
|
|
79
|
+
cause?: Error;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
58
82
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,MAAM,cAAc,GACpB,YAAY,GACZ,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,MAAM,cAAc,GACpB,YAAY,GACZ,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,wBAAwB,GACxB,aAAa,CAAC;AAEpB,0CAA0C;AAC1C,qBAAa,UAAW,SAAQ,KAAK;IACjC,SAAgB,IAAI,EAAE,cAAc,CAAgB;IACpD,SAAyB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAElD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,EAIvD;CACJ;AAED,iEAAiE;AACjE,qBAAa,kBAAmB,SAAQ,UAAU;IAC9C,SAAyB,IAAI,EAAG,oBAAoB,CAAU;IAC9D,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,SAAgB,K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Y,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,EAGtC;CACJ;AAED,mEAAmE;AACnE,qBAAa,sBAAuB,SAAQ,UAAU;IAClD,SAAyB,IAAI,EAAG,wBAAwB,CAAU;IAElE,YAAY,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,EAGtC;CACJ;AAED,sDAAsD;AACtD,qBAAa,WAAY,SAAQ,UAAU;IACvC,SAAyB,IAAI,EAAG,aAAa,CAAU;IACvD,sDAAsD;IACtD,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAyB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAElD,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,EAKrD;CACJ"}
|
package/dist/errors.js
CHANGED
|
@@ -68,4 +68,33 @@ export class ChunkEncodingError extends Http1Error {
|
|
|
68
68
|
this.cause = options?.cause;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
/** The transport closed before a complete response was received. */
|
|
72
|
+
export class ConnectionClosedError extends Http1Error {
|
|
73
|
+
kind = "ConnectionClosedError";
|
|
74
|
+
constructor(options) {
|
|
75
|
+
super("transport closed before response received", options);
|
|
76
|
+
this.name = "ConnectionClosedError";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** A new request was attempted on a connection that is closing. */
|
|
80
|
+
export class ConnectionClosingError extends Http1Error {
|
|
81
|
+
kind = "ConnectionClosingError";
|
|
82
|
+
constructor(options) {
|
|
83
|
+
super("connection is closing — no new requests allowed", options);
|
|
84
|
+
this.name = "ConnectionClosingError";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** A slice of bytes could not be decoded as ASCII. */
|
|
88
|
+
export class DecodeError extends Http1Error {
|
|
89
|
+
kind = "DecodeError";
|
|
90
|
+
/** The index in the buffer that was out of bounds. */
|
|
91
|
+
index;
|
|
92
|
+
cause;
|
|
93
|
+
constructor(index, options) {
|
|
94
|
+
super(`decodeAscii: index out of bounds at position ${index}`);
|
|
95
|
+
this.name = "DecodeError";
|
|
96
|
+
this.index = index;
|
|
97
|
+
this.cause = options?.cause;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
71
100
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,0CAA0C;AAC1C,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjB,IAAI,GAAmB,YAAY,CAAC;IAC3B,KAAK,CAAoB;IAElD,YAAY,OAAe,EAAE,OAA2B;QACpD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAChC,CAAC;CACJ;AAED,iEAAiE;AACjE,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IACrB,IAAI,GAAG,oBAA6B,CAAC;IAC9C,KAAK,CAAS;IAC9B,+EAA+E;IAC/D,KAAK,CAAoB;IAChB,KAAK,CAAoB;IAElD,YAAY,KAAa,EAAE,KAAwB,EAAE,OAA2B;QAC5E,KAAK,CAAC,qBAAqB,KAAK,oBAAoB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,OA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AU;IACxB,IAAI,GAAG,uBAAgC,CAAC;IAEjE,YAAY,OAA2B;QACnC,KAAK,CAAC,2CAA2C,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACxC,CAAC;CACJ;AAED,mEAAmE;AACnE,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IACzB,IAAI,GAAG,wBAAiC,CAAC;IAElE,YAAY,OAA2B;QACnC,KAAK,CAAC,iDAAiD,EAAE,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACzC,CAAC;CACJ;AAED,sDAAsD;AACtD,MAAM,OAAO,WAAY,SAAQ,UAAU;IACd,IAAI,GAAG,aAAsB,CAAC;IACvD,sDAAsD;IACtC,KAAK,CAAS;IACL,KAAK,CAAoB;IAElD,YAAY,KAAa,EAAE,OAA2B;QAClD,KAAK,CAAC,gDAAgD,KAAK,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAChC,CAAC;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Higher layers (cookies, fetch, profiles) compose exclusively through these exports.
|
|
6
6
|
*/
|
|
7
7
|
export { connectHttp1, Http1ConnectionImpl } from "./connection.js";
|
|
8
|
-
export { ChunkEncodingError, ContentEncodingError, Http1Error, InvalidResponseError, RedirectLimitError, } from "./errors.js";
|
|
9
|
-
export { type Headers, type ParseResponseResult, type StartLine, parseChunkedEncoding, parseResponse, serializeRequest, } from "./message.js";
|
|
10
|
-
export { decompressBody, isSupportedContentEncoding, type ContentEncoding } from "./decompress.js";
|
|
8
|
+
export { ChunkEncodingError, ConnectionClosedError, ConnectionClosingError, ContentEncodingError, DecodeError, Http1Error, InvalidResponseError, RedirectLimitError, } from "./errors.js";
|
|
9
|
+
export { type Headers, type ParseResponseResult, type StartLine, formatHeaderName, parseChunkedEncoding, parseResponse, serializeRequest, } from "./message.js";
|
|
10
|
+
export { decompressBody, isSupportedContentEncoding, type ContentEncoding, type DecompressionProvider, } from "./decompress.js";
|
|
11
11
|
export { followRedirects, isRedirectStatus, resolveRedirectUrl, type FollowRedirectsOptions, type RedirectStatusCode, } from "./redirect.js";
|
|
12
|
-
export { type Http1CloseReason, type Http1Connection, type Http1ConnectionId, type Http1ConnectionState, type Http1Options, type HttpBodyKind, type HttpMethod, type HttpRequest, type HttpResponse, type CookieInterceptor, type CookieUrl, } from "./types.js";
|
|
13
|
-
export { assertNever } from "./utils.js";
|
|
12
|
+
export { type Http1CloseReason, type Http1Connection, type Http1ConnectionId, type Http1ConnectionState, type Http1Options, type HttpBodyKind, type HttpMethod, type HeaderCasing, type HttpRequest, type HttpResponse, type CookieInterceptor, type CookieUrl, } from "./types.js";
|
|
13
|
+
export { assertNever, nodeRandomSource } from "./utils.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,oBAAoB,EACpB,aAAa,EACb,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACH,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,cAAc,EACd,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,qBAAqB,GAC7B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACH,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GAC1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Higher layers (cookies, fetch, profiles) compose exclusively through these exports.
|
|
6
6
|
*/
|
|
7
7
|
export { connectHttp1, Http1ConnectionImpl } from "./connection.js";
|
|
8
|
-
export { ChunkEncodingError, ContentEncodingError, Http1Error, InvalidResponseError, RedirectLimitError, } from "./errors.js";
|
|
9
|
-
export { parseChunkedEncoding, parseResponse, serializeRequest, } from "./message.js";
|
|
10
|
-
export { decompressBody, isSupportedContentEncoding } from "./decompress.js";
|
|
8
|
+
export { ChunkEncodingError, ConnectionClosedError, ConnectionClosingError, ContentEncodingError, DecodeError, Http1Error, InvalidResponseError, RedirectLimitError, } from "./errors.js";
|
|
9
|
+
export { formatHeaderName, parseChunkedEncoding, parseResponse, serializeRequest, } from "./message.js";
|
|
10
|
+
export { decompressBody, isSupportedContentEncoding, } from "./decompress.js";
|
|
11
11
|
export { followRedirects, isRedirectStatus, resolveRedirectUrl, } from "./redirect.js";
|
|
12
12
|
export {} from "./types.js";
|
|
13
|
-
export { assertNever } from "./utils.js";
|
|
13
|
+
export { assertNever, nodeRandomSource } from "./utils.js";
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAIH,oBAAoB,EACpB,aAAa,EACb,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACH,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAIH,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,cAAc,EACd,0BAA0B,GAG7B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACH,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAGrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAaN,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/message.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Pure protocol logic — no I/O. Takes and returns `Uint8Array` so it can be
|
|
5
5
|
* tested in isolation and composed over any byte stream.
|
|
6
6
|
*/
|
|
7
|
-
import type { HttpRequest, HttpResponse } from "./types.js";
|
|
7
|
+
import type { HeaderCasing, HttpRequest, HttpResponse } from "./types.js";
|
|
8
8
|
/** The start-line of an HTTP/1.1 message — discriminated by direction. */
|
|
9
9
|
export type StartLine = {
|
|
10
10
|
readonly kind: "request";
|
|
@@ -24,11 +24,27 @@ export interface ParseResponseResult {
|
|
|
24
24
|
readonly response: HttpResponse;
|
|
25
25
|
readonly bytesConsumed: number;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Format a header field name according to the requested casing mode.
|
|
29
|
+
*
|
|
30
|
+
* - `lowercase` — RFC 7230 §3.2 convention; matches `node:http` (default).
|
|
31
|
+
* - `title` — first letter capitalized, rest lowercased. Mirrors the mixed-case
|
|
32
|
+
* header names real browsers emit over HTTP/1.1 (e.g. `Content-Type`).
|
|
33
|
+
* - `original` — name returned verbatim, exactly as stored by the caller.
|
|
34
|
+
*
|
|
35
|
+
* The `default` arm uses {@link assertNever} so adding a new {@link HeaderCasing}
|
|
36
|
+
* variant forces this function to compile-error until handled.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatHeaderName(name: string, mode?: HeaderCasing): string;
|
|
27
39
|
/**
|
|
28
40
|
* Serialize an HTTP/1.1 request into wire bytes.
|
|
29
41
|
*
|
|
30
42
|
* Produces `request-line CRLF headers CRLF body` per RFC 7230. The body is
|
|
31
43
|
* appended verbatim — chunking and content-length are the caller's concern.
|
|
44
|
+
*
|
|
45
|
+
* Header field names are cased per {@link HttpRequest.headerCasing}
|
|
46
|
+
* (default `lowercase`). Headers iterate in `Map` insertion order so callers
|
|
47
|
+
* control the on-the-wire ordering.
|
|
32
48
|
*/
|
|
33
49
|
export declare function serializeRequest(req: HttpRequest): Uint8Array;
|
|
34
50
|
/**
|
package/dist/message.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1E,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxG;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtH,6CAA6C;AAC7C,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,YAA0B,GAAG,MAAM,CAWvF;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,CAoB7D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,mBAAmB,CAwDlE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAuB,oBAAoB,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CA6EzG"}
|
package/dist/message.js
CHANGED
|
@@ -6,20 +6,47 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { InvalidResponseError, ChunkEncodingError } from "./errors.js";
|
|
8
8
|
import { assertNever, decodeAscii, consumeTrailers } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Format a header field name according to the requested casing mode.
|
|
11
|
+
*
|
|
12
|
+
* - `lowercase` — RFC 7230 §3.2 convention; matches `node:http` (default).
|
|
13
|
+
* - `title` — first letter capitalized, rest lowercased. Mirrors the mixed-case
|
|
14
|
+
* header names real browsers emit over HTTP/1.1 (e.g. `Content-Type`).
|
|
15
|
+
* - `original` — name returned verbatim, exactly as stored by the caller.
|
|
16
|
+
*
|
|
17
|
+
* The `default` arm uses {@link assertNever} so adding a new {@link HeaderCasing}
|
|
18
|
+
* variant forces this function to compile-error until handled.
|
|
19
|
+
*/
|
|
20
|
+
export function formatHeaderName(name, mode = "lowercase") {
|
|
21
|
+
switch (mode) {
|
|
22
|
+
case "lowercase":
|
|
23
|
+
return name.toLowerCase();
|
|
24
|
+
case "title":
|
|
25
|
+
return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
|
26
|
+
case "original":
|
|
27
|
+
return name;
|
|
28
|
+
default:
|
|
29
|
+
return assertNever(mode);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
9
32
|
/**
|
|
10
33
|
* Serialize an HTTP/1.1 request into wire bytes.
|
|
11
34
|
*
|
|
12
35
|
* Produces `request-line CRLF headers CRLF body` per RFC 7230. The body is
|
|
13
36
|
* appended verbatim — chunking and content-length are the caller's concern.
|
|
37
|
+
*
|
|
38
|
+
* Header field names are cased per {@link HttpRequest.headerCasing}
|
|
39
|
+
* (default `lowercase`). Headers iterate in `Map` insertion order so callers
|
|
40
|
+
* control the on-the-wire ordering.
|
|
14
41
|
*/
|
|
15
42
|
export function serializeRequest(req) {
|
|
16
43
|
const lines = [`${req.method} ${req.url} HTTP/1.1`];
|
|
44
|
+
const casing = req.headerCasing ?? "lowercase";
|
|
17
45
|
for (const [name, value] of req.headers) {
|
|
18
|
-
|
|
19
|
-
lines.push(`${name.toLowerCase()}: ${value}`);
|
|
46
|
+
lines.push(`${formatHeaderName(name, casing)}: ${value}`);
|
|
20
47
|
}
|
|
21
48
|
lines.push("", "");
|
|
22
|
-
const headerBytes =
|
|
49
|
+
const headerBytes = new TextEncoder().encode(lines.join("\r\n"));
|
|
23
50
|
switch (req.body.kind) {
|
|
24
51
|
case "empty":
|
|
25
52
|
return new Uint8Array(headerBytes);
|
|
@@ -42,7 +69,7 @@ export function serializeRequest(req) {
|
|
|
42
69
|
* @throws {InvalidResponseError} if the bytes cannot be parsed as a response.
|
|
43
70
|
*/
|
|
44
71
|
export function parseResponse(buf) {
|
|
45
|
-
const text =
|
|
72
|
+
const text = decodeAscii(buf, 0, buf.length);
|
|
46
73
|
const headerEnd = text.indexOf("\r\n\r\n");
|
|
47
74
|
if (headerEnd === -1) {
|
|
48
75
|
throw new InvalidResponseError(text.slice(0, 120));
|
package/dist/message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,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GED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* HTTP/1.1 client over any duplex byte stream. This package owns NO knowledge
|
|
5
5
|
* of TLS, TCP, or DNS — it composes exclusively over `@browsercore/transport`.
|
|
6
6
|
*/
|
|
7
|
-
import type { Transport } from "@browsercore/transport";
|
|
7
|
+
import type { RandomSource, Transport } from "@browsercore/transport";
|
|
8
|
+
import type { DecompressionProvider } from "./decompress.js";
|
|
9
|
+
export type { RandomSource };
|
|
8
10
|
/** Branded HTTP/1.1 connection identifier. */
|
|
9
11
|
export type Http1ConnectionId = string & {
|
|
10
12
|
__brand: "Http1ConnectionId";
|
|
@@ -25,13 +27,29 @@ export type HttpBodyKind = {
|
|
|
25
27
|
readonly kind: "bytes";
|
|
26
28
|
readonly data: Uint8Array;
|
|
27
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* How header field names are cased when serialized to the wire by
|
|
32
|
+
* {@link serializeRequest}.
|
|
33
|
+
*
|
|
34
|
+
* - `lowercase` — RFC 7230 §3.2 convention; matches `node:http` (default).
|
|
35
|
+
* - `title` — first letter capitalized, rest lowercased. Real browsers send
|
|
36
|
+
* mixed-case header names over HTTP/1.1 (e.g. `Content-Type`, `User-Agent`);
|
|
37
|
+
* this mode reproduces that for impersonation.
|
|
38
|
+
* - `original` — names emitted verbatim, exactly as stored by the caller.
|
|
39
|
+
*/
|
|
40
|
+
export type HeaderCasing = "lowercase" | "title" | "original";
|
|
28
41
|
/** A fully-serializable HTTP/1.1 request. */
|
|
29
42
|
export interface HttpRequest {
|
|
30
43
|
readonly method: HttpMethod;
|
|
31
44
|
readonly url: string;
|
|
32
|
-
/** Headers are
|
|
45
|
+
/** Headers are stored as a ReadonlyMap (case-insensitive on the wire). */
|
|
33
46
|
readonly headers: ReadonlyMap<string, string>;
|
|
34
47
|
readonly body: HttpBodyKind;
|
|
48
|
+
/**
|
|
49
|
+
* Controls how header field names are cased on the wire. Defaults to
|
|
50
|
+
* `lowercase` for backward compatibility when omitted.
|
|
51
|
+
*/
|
|
52
|
+
readonly headerCasing?: HeaderCasing;
|
|
35
53
|
}
|
|
36
54
|
/** A parsed HTTP/1.1 response. */
|
|
37
55
|
export interface HttpResponse {
|
|
@@ -78,6 +96,21 @@ export interface Http1Connection {
|
|
|
78
96
|
/** Gracefully close the connection. Resolves once no requests are in flight. */
|
|
79
97
|
close(reason?: Http1CloseReason): Promise<void>;
|
|
80
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Clock for time-dependent operations. Injected via {@link Http1Options} so
|
|
101
|
+
* callers control the time source — keeps the package testable against a
|
|
102
|
+
* deterministic clock (reproducible id generation) and embeddable in non-Node
|
|
103
|
+
* hosts (browsers, workers) where `Date.now()` may not be the desired source.
|
|
104
|
+
*
|
|
105
|
+
* `now()` MUST return milliseconds since the Unix epoch, matching the contract
|
|
106
|
+
* of `Date.now()`.
|
|
107
|
+
*/
|
|
108
|
+
export interface Clock {
|
|
109
|
+
/** Current time in milliseconds since the Unix epoch. */
|
|
110
|
+
now(): number;
|
|
111
|
+
}
|
|
112
|
+
/** The default clock — delegates to the platform `Date.now()`. */
|
|
113
|
+
export declare const systemClock: Clock;
|
|
81
114
|
/**
|
|
82
115
|
* Cookie-jar integration seam.
|
|
83
116
|
*
|
|
@@ -127,5 +160,27 @@ export interface Http1Options {
|
|
|
127
160
|
* http1 performs no cookie storage of its own.
|
|
128
161
|
*/
|
|
129
162
|
readonly cookieInterceptor?: CookieInterceptor;
|
|
163
|
+
/**
|
|
164
|
+
* Content-encoding decompression backend. http1 does NOT own a zlib
|
|
165
|
+
* provider — it depends only on the {@link DecompressionProvider}
|
|
166
|
+
* interface, never on a concrete implementation. The @browsercore/fetch
|
|
167
|
+
* layer injects its `@browsercore/compression` singleton here.
|
|
168
|
+
*
|
|
169
|
+
* When absent and a response carries a `content-encoding`, the connection
|
|
170
|
+
* raises {@link ContentEncodingError} rather than returning corrupt bytes.
|
|
171
|
+
*/
|
|
172
|
+
readonly decompressionProvider?: DecompressionProvider;
|
|
173
|
+
/**
|
|
174
|
+
* Clock for time-dependent operations. Defaults to {@link systemClock}
|
|
175
|
+
* (delegates to `Date.now()`). Inject a deterministic clock for
|
|
176
|
+
* reproducible ids in tests.
|
|
177
|
+
*/
|
|
178
|
+
readonly clock?: Clock;
|
|
179
|
+
/**
|
|
180
|
+
* Source of cryptographically-strong random bytes. Used for connection IDs
|
|
181
|
+
* and any other randomness needs. Defaults to `nodeRandomSource` (a
|
|
182
|
+
* `node:crypto.randomBytes`-backed source) when not provided.
|
|
183
|
+
*/
|
|
184
|
+
readonly random?: RandomSource;
|
|
130
185
|
}
|
|
131
186
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAI7D,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE1E,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAChB,KAAK,GACL,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,GACP,MAAM,GACN,SAAS,GACT,OAAO,GACP,SAAS,CAAC;AAEhB;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC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QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC7B;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAY;IACzB,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAC/C;;;;;;;;OAQG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;CAClC"}
|
package/dist/types.js
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* HTTP/1.1 client over any duplex byte stream. This package owns NO knowledge
|
|
5
5
|
* of TLS, TCP, or DNS — it composes exclusively over `@browsercore/transport`.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/** The default clock — delegates to the platform `Date.now()`. */
|
|
8
|
+
export const systemClock = {
|
|
9
|
+
now: () => Date.now(),
|
|
10
|
+
};
|
|
8
11
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuHH,kEAAkE;AAClE,MAAM,CAAC,MAAM,WAAW,GAAU;IAC9B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;CACxB,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -4,15 +4,30 @@
|
|
|
4
4
|
* Kept dependency-free so every package can copy the pattern without pulling in
|
|
5
5
|
* cross-package imports.
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
7
|
+
import { type Http1ConnectionId, type Clock, type RandomSource } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Default {@link RandomSource} backed by `node:crypto.randomBytes`.
|
|
10
|
+
*
|
|
11
|
+
* @browsercore/transport exposes a factory (`createRandomSource`) rather than a
|
|
12
|
+
* shared instance; we materialize one default source here so the rest of http1
|
|
13
|
+
* (and downstream callers via the public re-export) can reference a stable name.
|
|
14
|
+
*/
|
|
15
|
+
export declare const nodeRandomSource: RandomSource;
|
|
8
16
|
/**
|
|
9
17
|
* Exhaustiveness check for `switch`/`if-else` over discriminated unions.
|
|
10
18
|
* Call in the `default` branch: `default: assertNever(x)`.
|
|
11
19
|
* Adding a new union member forces every handler to compile-error until handled.
|
|
12
20
|
*/
|
|
13
21
|
export declare function assertNever(x: never): never;
|
|
14
|
-
/**
|
|
15
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Generate a branded HTTP/1.1 connection id.
|
|
24
|
+
*
|
|
25
|
+
* The trailing segment is drawn from `random` so the id is unique without
|
|
26
|
+
* relying on `Math.random()`. This is the single sanctioned home for
|
|
27
|
+
* randomness in http1 — other modules must call this rather than reaching for
|
|
28
|
+
* randomness directly.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createId(prefix: string, random: RandomSource, clock?: Clock): Http1ConnectionId;
|
|
16
31
|
/**
|
|
17
32
|
* Explicit handle for a promise that is resolved/rejected from the outside.
|
|
18
33
|
*
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAe,KAAK,iBAAiB,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAIhG;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAAmC,CAAC;AAEnE;;;;GAIG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,KAAK,GAAE,KAAmB,GAC3B,iBAAiB,CAQnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAQ/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAYtE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAU/E"}
|
package/dist/utils.js
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* Kept dependency-free so every package can copy the pattern without pulling in
|
|
5
5
|
* cross-package imports.
|
|
6
6
|
*/
|
|
7
|
+
import { systemClock } from "./types.js";
|
|
8
|
+
import { DecodeError } from "./errors.js";
|
|
9
|
+
import { createRandomSource } from "@browsercore/transport";
|
|
10
|
+
/**
|
|
11
|
+
* Default {@link RandomSource} backed by `node:crypto.randomBytes`.
|
|
12
|
+
*
|
|
13
|
+
* @browsercore/transport exposes a factory (`createRandomSource`) rather than a
|
|
14
|
+
* shared instance; we materialize one default source here so the rest of http1
|
|
15
|
+
* (and downstream callers via the public re-export) can reference a stable name.
|
|
16
|
+
*/
|
|
17
|
+
export const nodeRandomSource = createRandomSource();
|
|
7
18
|
/**
|
|
8
19
|
* Exhaustiveness check for `switch`/`if-else` over discriminated unions.
|
|
9
20
|
* Call in the `default` branch: `default: assertNever(x)`.
|
|
@@ -13,9 +24,22 @@
|
|
|
13
24
|
export function assertNever(x) {
|
|
14
25
|
throw new Error(`Unexpected value: ${JSON.stringify(x)}`);
|
|
15
26
|
}
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Generate a branded HTTP/1.1 connection id.
|
|
29
|
+
*
|
|
30
|
+
* The trailing segment is drawn from `random` so the id is unique without
|
|
31
|
+
* relying on `Math.random()`. This is the single sanctioned home for
|
|
32
|
+
* randomness in http1 — other modules must call this rather than reaching for
|
|
33
|
+
* randomness directly.
|
|
34
|
+
*/
|
|
35
|
+
export function createId(prefix, random, clock = systemClock) {
|
|
36
|
+
// 3 bytes → 24 bits of entropy, plenty for a ~1e6-space suffix.
|
|
37
|
+
const bytes = random.randomBytes(3);
|
|
38
|
+
const hi = bytes[0] ?? 0;
|
|
39
|
+
const mid = bytes[1] ?? 0;
|
|
40
|
+
const lo = bytes[2] ?? 0;
|
|
41
|
+
const suffix = ((hi << 16) | (mid << 8) | lo) % 1_000_000;
|
|
42
|
+
return `${prefix}_${clock.now().toString(36)}_${suffix.toString(36)}`;
|
|
19
43
|
}
|
|
20
44
|
/** Create a {@link Deferred} whose `resolve`/`reject` can be invoked elsewhere. */
|
|
21
45
|
export function createDeferred() {
|
|
@@ -62,7 +86,7 @@ export function decodeAscii(buf, start, end) {
|
|
|
62
86
|
for (let i = start; i < end; i++) {
|
|
63
87
|
const byte = buf[i];
|
|
64
88
|
if (byte === undefined) {
|
|
65
|
-
throw new
|
|
89
|
+
throw new DecodeError(i);
|
|
66
90
|
}
|
|
67
91
|
out += String.fromCodePoint(byte);
|
|
68
92
|
}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAyD,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiB,kBAAkB,EAAE,CAAC;AAEnE;;;;GAIG;AACH,6DAA6D;AAC7D,MAAM,UAAU,WAAW,CAAC,CAAQ;IAChC,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACpB,MAAc,EACd,MAAoB,EACpB,KAAK,GAAU,WAAW;IAE1B,gEAAgE;IAChE,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACz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AW;IACnE,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browsercore/http1",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "HTTP/1.1 client over any duplex byte stream. No knowledge of TLS or TCP — only the protocol.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
15
16
|
"main": "./dist/index.js",
|
|
16
17
|
"types": "./dist/index.d.ts",
|
|
17
18
|
"exports": {
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
26
|
+
"bin",
|
|
25
27
|
"LICENSE",
|
|
26
28
|
"README.md"
|
|
27
29
|
],
|
|
@@ -31,14 +33,17 @@
|
|
|
31
33
|
},
|
|
32
34
|
"scripts": {
|
|
33
35
|
"clean": "rm -rf dist",
|
|
34
|
-
"build": "tsc -p tsconfig.
|
|
36
|
+
"build": "tsc -p tsconfig.json",
|
|
35
37
|
"prepublishOnly": "npm run clean && npm run build",
|
|
36
38
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
37
39
|
"test": "vitest run",
|
|
38
40
|
"lint": "oxlint --type-aware src/"
|
|
39
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@browsercore/transport": "0.2.4"
|
|
44
|
+
},
|
|
40
45
|
"devDependencies": {
|
|
41
|
-
"@browsercore/
|
|
46
|
+
"@browsercore/compression": "0.2.0",
|
|
42
47
|
"@types/node": "^26.1.2",
|
|
43
48
|
"@vitest/coverage-v8": "^4.1.10",
|
|
44
49
|
"oxlint": "^1.76.0",
|
|
@@ -46,10 +51,6 @@
|
|
|
46
51
|
"typescript": "^7.0.0",
|
|
47
52
|
"vitest": "^4.1.10"
|
|
48
53
|
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@browsercore/compression": "0.2.0",
|
|
51
|
-
"@browsercore/transport": "0.2.0"
|
|
52
|
-
},
|
|
53
54
|
"engines": {
|
|
54
55
|
"node": ">=26.0.0"
|
|
55
56
|
}
|