@npy/fetch 0.1.1 → 0.1.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/_internal/decode-stream-error.cjs +18 -0
- package/_internal/decode-stream-error.d.cts +11 -0
- package/_internal/decode-stream-error.d.ts +11 -0
- package/_internal/decode-stream-error.js +18 -0
- package/_internal/error-mapping.cjs +44 -0
- package/_internal/error-mapping.d.cts +15 -0
- package/_internal/error-mapping.d.ts +15 -0
- package/_internal/error-mapping.js +41 -0
- package/_internal/guards.cjs +5 -6
- package/{src/_internal → _internal}/guards.d.cts +2 -0
- package/{src/_internal → _internal}/guards.d.ts +2 -0
- package/_internal/guards.js +5 -7
- package/{src/_internal → _internal}/net.d.cts +1 -2
- package/{src/_internal → _internal}/net.d.ts +1 -2
- package/_internal/symbols.cjs +4 -0
- package/_internal/symbols.d.cts +1 -0
- package/_internal/symbols.d.ts +1 -0
- package/_internal/symbols.js +4 -0
- package/agent-pool.cjs +23 -5
- package/agent-pool.d.cts +2 -0
- package/agent-pool.d.ts +2 -0
- package/agent-pool.js +23 -5
- package/agent.cjs +17 -14
- package/agent.js +17 -14
- package/body.cjs +10 -59
- package/body.d.cts +12 -0
- package/body.d.ts +12 -0
- package/body.js +11 -60
- package/dialers/proxy.cjs +7 -0
- package/{src/dialers → dialers}/proxy.d.cts +11 -3
- package/{src/dialers → dialers}/proxy.d.ts +11 -3
- package/dialers/proxy.js +7 -0
- package/dialers/tcp.cjs +22 -0
- package/{src/dialers → dialers}/tcp.d.cts +23 -2
- package/{src/dialers → dialers}/tcp.d.ts +23 -2
- package/dialers/tcp.js +22 -0
- package/encoding.cjs +32 -13
- package/encoding.d.cts +35 -0
- package/encoding.d.ts +35 -0
- package/encoding.js +32 -13
- package/fetch.cjs +279 -43
- package/fetch.d.cts +58 -0
- package/fetch.d.ts +58 -0
- package/fetch.js +278 -43
- package/http-client.cjs +47 -5
- package/http-client.d.cts +39 -0
- package/http-client.d.ts +39 -0
- package/http-client.js +47 -5
- package/index.cjs +7 -3
- package/index.d.cts +14 -1
- package/index.d.ts +14 -1
- package/index.js +6 -4
- package/io/io.cjs +68 -4
- package/{src/io → io}/io.d.cts +1 -1
- package/{src/io → io}/io.d.ts +1 -1
- package/io/io.js +68 -4
- package/io/readers.cjs +14 -54
- package/io/readers.d.cts +69 -0
- package/io/readers.d.ts +69 -0
- package/io/readers.js +14 -54
- package/io/writers.cjs +10 -5
- package/{src/io → io}/writers.d.cts +1 -1
- package/{src/io → io}/writers.d.ts +1 -1
- package/io/writers.js +11 -6
- package/package.json +18 -2
- package/types/agent.d.cts +72 -0
- package/types/agent.d.ts +72 -0
- package/{src/types → types}/dialer.d.cts +3 -0
- package/{src/types → types}/dialer.d.ts +3 -0
- package/_internal/error-adapters.cjs +0 -146
- package/_internal/error-adapters.js +0 -142
- package/src/_internal/error-adapters.d.cts +0 -22
- package/src/_internal/error-adapters.d.ts +0 -22
- package/src/agent-pool.d.cts +0 -2
- package/src/agent-pool.d.ts +0 -2
- package/src/body.d.cts +0 -23
- package/src/body.d.ts +0 -23
- package/src/encoding.d.cts +0 -24
- package/src/encoding.d.ts +0 -24
- package/src/fetch.d.cts +0 -36
- package/src/fetch.d.ts +0 -36
- package/src/http-client.d.cts +0 -23
- package/src/http-client.d.ts +0 -23
- package/src/index.d.cts +0 -7
- package/src/index.d.ts +0 -7
- package/src/io/readers.d.cts +0 -199
- package/src/io/readers.d.ts +0 -199
- package/src/types/agent.d.cts +0 -128
- package/src/types/agent.d.ts +0 -128
- package/tests/test-utils.d.cts +0 -8
- package/tests/test-utils.d.ts +0 -8
- /package/{src/_internal → _internal}/consts.d.cts +0 -0
- /package/{src/_internal → _internal}/consts.d.ts +0 -0
- /package/{src/_internal → _internal}/promises.d.cts +0 -0
- /package/{src/_internal → _internal}/promises.d.ts +0 -0
- /package/{src/_internal → _internal}/streams.d.cts +0 -0
- /package/{src/_internal → _internal}/streams.d.ts +0 -0
- /package/{src/agent.d.cts → agent.d.cts} +0 -0
- /package/{src/agent.d.ts → agent.d.ts} +0 -0
- /package/{src/dialers → dialers}/index.d.cts +0 -0
- /package/{src/dialers → dialers}/index.d.ts +0 -0
- /package/{src/errors.d.cts → errors.d.cts} +0 -0
- /package/{src/errors.d.ts → errors.d.ts} +0 -0
- /package/{src/io → io}/_utils.d.cts +0 -0
- /package/{src/io → io}/_utils.d.ts +0 -0
- /package/{src/io → io}/buf-writer.d.cts +0 -0
- /package/{src/io → io}/buf-writer.d.ts +0 -0
- /package/{src/types → types}/index.d.cts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
package/src/body.d.cts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
import { FormDataPolyfill } from './_internal/guards';
|
|
3
|
-
export type BodyInit = Exclude<RequestInit["body"], undefined | null> | FormDataPolyfill | Readable;
|
|
4
|
-
export interface BodyState {
|
|
5
|
-
contentLength: number | null;
|
|
6
|
-
contentType: string | null;
|
|
7
|
-
body: Readable | ReadableStream | Uint8Array | null;
|
|
8
|
-
}
|
|
9
|
-
export declare const getFormDataLength: (form: FormData, boundary: string) => number;
|
|
10
|
-
export declare const extractBody: (object: BodyInit | null) => BodyState;
|
|
11
|
-
declare const kBodyInternals: unique symbol;
|
|
12
|
-
export declare class Body {
|
|
13
|
-
private [kBodyInternals];
|
|
14
|
-
constructor(init: BodyInit | null);
|
|
15
|
-
get body(): Uint8Array<ArrayBufferLike> | Readable | ReadableStream<any> | null;
|
|
16
|
-
get bodyUsed(): boolean;
|
|
17
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
18
|
-
formData(): Promise<FormData>;
|
|
19
|
-
blob(): Promise<Blob>;
|
|
20
|
-
json(): Promise<any>;
|
|
21
|
-
text(): Promise<string>;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
package/src/body.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
import { FormDataPolyfill } from './_internal/guards';
|
|
3
|
-
export type BodyInit = Exclude<RequestInit["body"], undefined | null> | FormDataPolyfill | Readable;
|
|
4
|
-
export interface BodyState {
|
|
5
|
-
contentLength: number | null;
|
|
6
|
-
contentType: string | null;
|
|
7
|
-
body: Readable | ReadableStream | Uint8Array | null;
|
|
8
|
-
}
|
|
9
|
-
export declare const getFormDataLength: (form: FormData, boundary: string) => number;
|
|
10
|
-
export declare const extractBody: (object: BodyInit | null) => BodyState;
|
|
11
|
-
declare const kBodyInternals: unique symbol;
|
|
12
|
-
export declare class Body {
|
|
13
|
-
private [kBodyInternals];
|
|
14
|
-
constructor(init: BodyInit | null);
|
|
15
|
-
get body(): Uint8Array<ArrayBufferLike> | Readable | ReadableStream<any> | null;
|
|
16
|
-
get bodyUsed(): boolean;
|
|
17
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
18
|
-
formData(): Promise<FormData>;
|
|
19
|
-
blob(): Promise<Blob>;
|
|
20
|
-
json(): Promise<any>;
|
|
21
|
-
text(): Promise<string>;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
package/src/encoding.d.cts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type ByteStream = ReadableStream<Uint8Array>;
|
|
2
|
-
type ByteTransform = TransformStream<Uint8Array, Uint8Array>;
|
|
3
|
-
export declare function decodeStream(stream: ByteStream, contentEncoding?: string | string[]): ByteStream;
|
|
4
|
-
export declare function decodeStream(stream: AsyncIterable<Uint8Array>, contentEncoding?: string | string[]): AsyncIterable<Uint8Array> | ByteStream;
|
|
5
|
-
export declare function encodeStream(stream: ByteStream, contentEncoding?: string | string[]): ByteStream;
|
|
6
|
-
export declare function encodeStream(stream: AsyncIterable<Uint8Array>, contentEncoding?: string | string[]): AsyncIterable<Uint8Array> | ByteStream;
|
|
7
|
-
/**
|
|
8
|
-
* Create a series of decoding streams based on the content-encoding header. The
|
|
9
|
-
* resulting streams should be piped together to decode the content.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc9110#section-8.4.1}
|
|
12
|
-
*/
|
|
13
|
-
export declare function createDecoders(contentEncoding?: string | string[]): ByteTransform[];
|
|
14
|
-
/**
|
|
15
|
-
* Create a series of encoding streams based on the content-encoding header (or
|
|
16
|
-
* transfer-coding list).
|
|
17
|
-
*
|
|
18
|
-
* The resulting streams should be piped together to apply the encoding in the
|
|
19
|
-
* declared order.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc9110#section-8.4.1}
|
|
22
|
-
*/
|
|
23
|
-
export declare function createEncoders(contentEncoding?: string | string[]): ByteTransform[];
|
|
24
|
-
export {};
|
package/src/encoding.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type ByteStream = ReadableStream<Uint8Array>;
|
|
2
|
-
type ByteTransform = TransformStream<Uint8Array, Uint8Array>;
|
|
3
|
-
export declare function decodeStream(stream: ByteStream, contentEncoding?: string | string[]): ByteStream;
|
|
4
|
-
export declare function decodeStream(stream: AsyncIterable<Uint8Array>, contentEncoding?: string | string[]): AsyncIterable<Uint8Array> | ByteStream;
|
|
5
|
-
export declare function encodeStream(stream: ByteStream, contentEncoding?: string | string[]): ByteStream;
|
|
6
|
-
export declare function encodeStream(stream: AsyncIterable<Uint8Array>, contentEncoding?: string | string[]): AsyncIterable<Uint8Array> | ByteStream;
|
|
7
|
-
/**
|
|
8
|
-
* Create a series of decoding streams based on the content-encoding header. The
|
|
9
|
-
* resulting streams should be piped together to decode the content.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc9110#section-8.4.1}
|
|
12
|
-
*/
|
|
13
|
-
export declare function createDecoders(contentEncoding?: string | string[]): ByteTransform[];
|
|
14
|
-
/**
|
|
15
|
-
* Create a series of encoding streams based on the content-encoding header (or
|
|
16
|
-
* transfer-coding list).
|
|
17
|
-
*
|
|
18
|
-
* The resulting streams should be piped together to apply the encoding in the
|
|
19
|
-
* declared order.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc9110#section-8.4.1}
|
|
22
|
-
*/
|
|
23
|
-
export declare function createEncoders(contentEncoding?: string | string[]): ByteTransform[];
|
|
24
|
-
export {};
|
package/src/fetch.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BodyInit as FetchBodyInit } from './body';
|
|
2
|
-
import { HttpClientOptions, HttpClient } from './http-client';
|
|
3
|
-
export interface RequestInit extends Omit<globalThis.RequestInit, "body" | "headers"> {
|
|
4
|
-
body?: FetchBodyInit | null;
|
|
5
|
-
headers?: HeadersInit;
|
|
6
|
-
/**
|
|
7
|
-
* Optional client override for this call.
|
|
8
|
-
*
|
|
9
|
-
* Reader/Writer I/O options are configured at the client/pool level, not
|
|
10
|
-
* per request.
|
|
11
|
-
*/
|
|
12
|
-
client?: HttpClient;
|
|
13
|
-
}
|
|
14
|
-
/** Clearer export for consumers that want to avoid shadowing the global name. */
|
|
15
|
-
export interface FetchRequestInit extends RequestInit {
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Options used only for constructing the default internal `HttpClient`.
|
|
19
|
-
*
|
|
20
|
-
* These are high-level client/pool/socket/I-O options; low-level Readers/Writers
|
|
21
|
-
* are not configured per request through this fetch-like API.
|
|
22
|
-
*/
|
|
23
|
-
export interface FetchOptions extends HttpClientOptions {
|
|
24
|
-
}
|
|
25
|
-
export interface FetchLike {
|
|
26
|
-
(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
29
|
-
readonly client: HttpClient;
|
|
30
|
-
}
|
|
31
|
-
export declare function normalizeHeaders(headers?: HeadersInit): Headers;
|
|
32
|
-
export declare function createFetch(client?: HttpClient): FetchLike;
|
|
33
|
-
export type { HttpClientOptions };
|
|
34
|
-
export { HttpClient };
|
|
35
|
-
export declare const fetch: FetchLike;
|
|
36
|
-
export default fetch;
|
package/src/fetch.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BodyInit as FetchBodyInit } from './body';
|
|
2
|
-
import { HttpClientOptions, HttpClient } from './http-client';
|
|
3
|
-
export interface RequestInit extends Omit<globalThis.RequestInit, "body" | "headers"> {
|
|
4
|
-
body?: FetchBodyInit | null;
|
|
5
|
-
headers?: HeadersInit;
|
|
6
|
-
/**
|
|
7
|
-
* Optional client override for this call.
|
|
8
|
-
*
|
|
9
|
-
* Reader/Writer I/O options are configured at the client/pool level, not
|
|
10
|
-
* per request.
|
|
11
|
-
*/
|
|
12
|
-
client?: HttpClient;
|
|
13
|
-
}
|
|
14
|
-
/** Clearer export for consumers that want to avoid shadowing the global name. */
|
|
15
|
-
export interface FetchRequestInit extends RequestInit {
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Options used only for constructing the default internal `HttpClient`.
|
|
19
|
-
*
|
|
20
|
-
* These are high-level client/pool/socket/I-O options; low-level Readers/Writers
|
|
21
|
-
* are not configured per request through this fetch-like API.
|
|
22
|
-
*/
|
|
23
|
-
export interface FetchOptions extends HttpClientOptions {
|
|
24
|
-
}
|
|
25
|
-
export interface FetchLike {
|
|
26
|
-
(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
29
|
-
readonly client: HttpClient;
|
|
30
|
-
}
|
|
31
|
-
export declare function normalizeHeaders(headers?: HeadersInit): Headers;
|
|
32
|
-
export declare function createFetch(client?: HttpClient): FetchLike;
|
|
33
|
-
export type { HttpClientOptions };
|
|
34
|
-
export { HttpClient };
|
|
35
|
-
export declare const fetch: FetchLike;
|
|
36
|
-
export default fetch;
|
package/src/http-client.d.cts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AgentPoolOptions, SendOptions } from './types/agent';
|
|
2
|
-
export declare class HttpClient implements AsyncDisposable {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(options?: HttpClient.Options);
|
|
5
|
-
send(options: SendOptions): Promise<Response>;
|
|
6
|
-
close(): Promise<void>;
|
|
7
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export declare namespace HttpClient {
|
|
10
|
-
/**
|
|
11
|
-
* High-level client configuration.
|
|
12
|
-
*
|
|
13
|
-
* At this layer, the API exposes:
|
|
14
|
-
* - pool management options
|
|
15
|
-
* - socket connection options
|
|
16
|
-
* - HTTP reader/writer options forwarded to the agent I/O layer
|
|
17
|
-
*/
|
|
18
|
-
interface Options extends AgentPoolOptions {
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/** Back-compat */
|
|
22
|
-
export interface HttpClientOptions extends HttpClient.Options {
|
|
23
|
-
}
|
package/src/http-client.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AgentPoolOptions, SendOptions } from './types/agent';
|
|
2
|
-
export declare class HttpClient implements AsyncDisposable {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(options?: HttpClient.Options);
|
|
5
|
-
send(options: SendOptions): Promise<Response>;
|
|
6
|
-
close(): Promise<void>;
|
|
7
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export declare namespace HttpClient {
|
|
10
|
-
/**
|
|
11
|
-
* High-level client configuration.
|
|
12
|
-
*
|
|
13
|
-
* At this layer, the API exposes:
|
|
14
|
-
* - pool management options
|
|
15
|
-
* - socket connection options
|
|
16
|
-
* - HTTP reader/writer options forwarded to the agent I/O layer
|
|
17
|
-
*/
|
|
18
|
-
interface Options extends AgentPoolOptions {
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/** Back-compat */
|
|
22
|
-
export interface HttpClientOptions extends HttpClient.Options {
|
|
23
|
-
}
|
package/src/index.d.cts
DELETED
package/src/index.d.ts
DELETED
package/src/io/readers.d.cts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { IClosable, IReadable } from '@fuman/io';
|
|
2
|
-
type Source = IReadable & IClosable;
|
|
3
|
-
export declare function sanitizeHeaderValue(v: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* Reader options shared across the HTTP/1 response pipeline.
|
|
6
|
-
*
|
|
7
|
-
* @namespace Readers
|
|
8
|
-
*/
|
|
9
|
-
export declare namespace Readers {
|
|
10
|
-
/**
|
|
11
|
-
* Buffering configuration.
|
|
12
|
-
*
|
|
13
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
14
|
-
*
|
|
15
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
16
|
-
* Defaults to 16 KiB.
|
|
17
|
-
*/
|
|
18
|
-
interface BufferingOptions {
|
|
19
|
-
bufferSize?: number;
|
|
20
|
-
highWaterMark?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Response size limits.
|
|
24
|
-
*
|
|
25
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
26
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
27
|
-
*
|
|
28
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
29
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
30
|
-
*/
|
|
31
|
-
interface SizeLimitOptions {
|
|
32
|
-
maxBodySize?: number | string;
|
|
33
|
-
maxDecodedBodySize?: number | string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Decompression behavior.
|
|
37
|
-
*
|
|
38
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
39
|
-
* Content-Encoding. Defaults to true.
|
|
40
|
-
*/
|
|
41
|
-
interface DecompressionOptions {
|
|
42
|
-
decompress?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Delimiter scanning limits.
|
|
46
|
-
*
|
|
47
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for a single CRLF-delimited line (excluding CRLF).
|
|
48
|
-
* Defaults to 64 KiB.
|
|
49
|
-
*
|
|
50
|
-
* @property {number} [maxBufferedBytes] - Maximum allowed buffered bytes while searching for CRLF.
|
|
51
|
-
* Defaults to 256 KiB.
|
|
52
|
-
*/
|
|
53
|
-
interface DelimiterLimitsOptions {
|
|
54
|
-
maxLineSize?: number;
|
|
55
|
-
maxBufferedBytes?: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Unified options shape suitable for fetch-like response parsing.
|
|
59
|
-
*/
|
|
60
|
-
type Options = LineReader.Options & BodyReader.Options & ChunkedBodyReader.Options;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* CRLF-delimited reader that preserves over-reads in an internal buffer.
|
|
64
|
-
*
|
|
65
|
-
* Key property: once you finish reading headers, any bytes already read beyond
|
|
66
|
-
* the header terminator stay buffered and will be returned by read().
|
|
67
|
-
*/
|
|
68
|
-
export declare class LineReader implements IReadable, IClosable {
|
|
69
|
-
#private;
|
|
70
|
-
close: () => Promise<void> | void;
|
|
71
|
-
/**
|
|
72
|
-
* LineReader configuration.
|
|
73
|
-
*
|
|
74
|
-
* @namespace LineReader
|
|
75
|
-
*/
|
|
76
|
-
static Options: never;
|
|
77
|
-
constructor(src: Source, opts?: LineReader.Options);
|
|
78
|
-
read(into: Uint8Array): Promise<number>;
|
|
79
|
-
readLine(): Promise<string | null>;
|
|
80
|
-
readHeaders(opts?: LineReader.ReadHeadersOptions): Promise<Headers>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* LineReader configuration.
|
|
84
|
-
*
|
|
85
|
-
* @namespace LineReader
|
|
86
|
-
*/
|
|
87
|
-
export declare namespace LineReader {
|
|
88
|
-
/**
|
|
89
|
-
* LineReader instance options.
|
|
90
|
-
*
|
|
91
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
92
|
-
*
|
|
93
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
94
|
-
* Defaults to 16 KiB.
|
|
95
|
-
*
|
|
96
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for a single CRLF-delimited line (excluding CRLF).
|
|
97
|
-
* Defaults to 64 KiB.
|
|
98
|
-
*
|
|
99
|
-
* @property {number} [maxBufferedBytes] - Maximum allowed buffered bytes while searching for CRLF.
|
|
100
|
-
* Defaults to 256 KiB.
|
|
101
|
-
*/
|
|
102
|
-
interface Options extends Readers.BufferingOptions, Readers.DelimiterLimitsOptions {
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Header parsing limits.
|
|
106
|
-
*
|
|
107
|
-
* @property {number} [maxHeaderSize] - Maximum allowed bytes for all header fields (including CRLFs).
|
|
108
|
-
* Defaults to 64 KiB.
|
|
109
|
-
*/
|
|
110
|
-
interface ReadHeadersOptions {
|
|
111
|
-
maxHeaderSize?: number;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Body reader that streams bytes with either a fixed Content-Length or until EOF.
|
|
116
|
-
*/
|
|
117
|
-
export declare class BodyReader implements IReadable, IClosable {
|
|
118
|
-
#private;
|
|
119
|
-
close: () => Promise<void> | void;
|
|
120
|
-
/**
|
|
121
|
-
* BodyReader configuration.
|
|
122
|
-
*
|
|
123
|
-
* @namespace BodyReader
|
|
124
|
-
*/
|
|
125
|
-
static Options: never;
|
|
126
|
-
constructor(src: Source, contentLength: number, opts?: BodyReader.Options);
|
|
127
|
-
read(into: Uint8Array): Promise<number>;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* BodyReader configuration.
|
|
131
|
-
*
|
|
132
|
-
* @namespace BodyReader
|
|
133
|
-
*/
|
|
134
|
-
export declare namespace BodyReader {
|
|
135
|
-
/**
|
|
136
|
-
* BodyReader instance options.
|
|
137
|
-
*
|
|
138
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
139
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
140
|
-
*
|
|
141
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
142
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
143
|
-
*
|
|
144
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
145
|
-
* Content-Encoding. Defaults to true.
|
|
146
|
-
*/
|
|
147
|
-
interface Options extends Readers.SizeLimitOptions, Readers.DecompressionOptions {
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* RFC 7230 chunked transfer-coding decoder.
|
|
152
|
-
*/
|
|
153
|
-
export declare class ChunkedBodyReader implements IReadable, IClosable {
|
|
154
|
-
#private;
|
|
155
|
-
close: () => Promise<void> | void;
|
|
156
|
-
/**
|
|
157
|
-
* ChunkedBodyReader configuration.
|
|
158
|
-
*
|
|
159
|
-
* @namespace ChunkedBodyReader
|
|
160
|
-
*/
|
|
161
|
-
static Options: never;
|
|
162
|
-
constructor(src: Source, opts?: ChunkedBodyReader.Options);
|
|
163
|
-
read(into: Uint8Array): Promise<number>;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* ChunkedBodyReader configuration.
|
|
167
|
-
*
|
|
168
|
-
* @namespace ChunkedBodyReader
|
|
169
|
-
*/
|
|
170
|
-
export declare namespace ChunkedBodyReader {
|
|
171
|
-
/**
|
|
172
|
-
* ChunkedBodyReader instance options.
|
|
173
|
-
*
|
|
174
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
175
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
176
|
-
*
|
|
177
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
178
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
179
|
-
*
|
|
180
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
181
|
-
* Content-Encoding. Defaults to true.
|
|
182
|
-
*
|
|
183
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
184
|
-
*
|
|
185
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
186
|
-
* Defaults to 16 KiB.
|
|
187
|
-
*
|
|
188
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for CRLF-delimited chunk control lines.
|
|
189
|
-
* Defaults to 64 KiB.
|
|
190
|
-
*
|
|
191
|
-
* @property {number} [maxChunkSize] - Maximum allowed bytes for any single chunk.
|
|
192
|
-
* Defaults to 16 MiB.
|
|
193
|
-
*/
|
|
194
|
-
interface Options extends BodyReader.Options, Readers.BufferingOptions {
|
|
195
|
-
maxLineSize?: number;
|
|
196
|
-
maxChunkSize?: number;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
export {};
|
package/src/io/readers.d.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { IClosable, IReadable } from '@fuman/io';
|
|
2
|
-
type Source = IReadable & IClosable;
|
|
3
|
-
export declare function sanitizeHeaderValue(v: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* Reader options shared across the HTTP/1 response pipeline.
|
|
6
|
-
*
|
|
7
|
-
* @namespace Readers
|
|
8
|
-
*/
|
|
9
|
-
export declare namespace Readers {
|
|
10
|
-
/**
|
|
11
|
-
* Buffering configuration.
|
|
12
|
-
*
|
|
13
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
14
|
-
*
|
|
15
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
16
|
-
* Defaults to 16 KiB.
|
|
17
|
-
*/
|
|
18
|
-
interface BufferingOptions {
|
|
19
|
-
bufferSize?: number;
|
|
20
|
-
highWaterMark?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Response size limits.
|
|
24
|
-
*
|
|
25
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
26
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
27
|
-
*
|
|
28
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
29
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
30
|
-
*/
|
|
31
|
-
interface SizeLimitOptions {
|
|
32
|
-
maxBodySize?: number | string;
|
|
33
|
-
maxDecodedBodySize?: number | string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Decompression behavior.
|
|
37
|
-
*
|
|
38
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
39
|
-
* Content-Encoding. Defaults to true.
|
|
40
|
-
*/
|
|
41
|
-
interface DecompressionOptions {
|
|
42
|
-
decompress?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Delimiter scanning limits.
|
|
46
|
-
*
|
|
47
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for a single CRLF-delimited line (excluding CRLF).
|
|
48
|
-
* Defaults to 64 KiB.
|
|
49
|
-
*
|
|
50
|
-
* @property {number} [maxBufferedBytes] - Maximum allowed buffered bytes while searching for CRLF.
|
|
51
|
-
* Defaults to 256 KiB.
|
|
52
|
-
*/
|
|
53
|
-
interface DelimiterLimitsOptions {
|
|
54
|
-
maxLineSize?: number;
|
|
55
|
-
maxBufferedBytes?: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Unified options shape suitable for fetch-like response parsing.
|
|
59
|
-
*/
|
|
60
|
-
type Options = LineReader.Options & BodyReader.Options & ChunkedBodyReader.Options;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* CRLF-delimited reader that preserves over-reads in an internal buffer.
|
|
64
|
-
*
|
|
65
|
-
* Key property: once you finish reading headers, any bytes already read beyond
|
|
66
|
-
* the header terminator stay buffered and will be returned by read().
|
|
67
|
-
*/
|
|
68
|
-
export declare class LineReader implements IReadable, IClosable {
|
|
69
|
-
#private;
|
|
70
|
-
close: () => Promise<void> | void;
|
|
71
|
-
/**
|
|
72
|
-
* LineReader configuration.
|
|
73
|
-
*
|
|
74
|
-
* @namespace LineReader
|
|
75
|
-
*/
|
|
76
|
-
static Options: never;
|
|
77
|
-
constructor(src: Source, opts?: LineReader.Options);
|
|
78
|
-
read(into: Uint8Array): Promise<number>;
|
|
79
|
-
readLine(): Promise<string | null>;
|
|
80
|
-
readHeaders(opts?: LineReader.ReadHeadersOptions): Promise<Headers>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* LineReader configuration.
|
|
84
|
-
*
|
|
85
|
-
* @namespace LineReader
|
|
86
|
-
*/
|
|
87
|
-
export declare namespace LineReader {
|
|
88
|
-
/**
|
|
89
|
-
* LineReader instance options.
|
|
90
|
-
*
|
|
91
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
92
|
-
*
|
|
93
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
94
|
-
* Defaults to 16 KiB.
|
|
95
|
-
*
|
|
96
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for a single CRLF-delimited line (excluding CRLF).
|
|
97
|
-
* Defaults to 64 KiB.
|
|
98
|
-
*
|
|
99
|
-
* @property {number} [maxBufferedBytes] - Maximum allowed buffered bytes while searching for CRLF.
|
|
100
|
-
* Defaults to 256 KiB.
|
|
101
|
-
*/
|
|
102
|
-
interface Options extends Readers.BufferingOptions, Readers.DelimiterLimitsOptions {
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Header parsing limits.
|
|
106
|
-
*
|
|
107
|
-
* @property {number} [maxHeaderSize] - Maximum allowed bytes for all header fields (including CRLFs).
|
|
108
|
-
* Defaults to 64 KiB.
|
|
109
|
-
*/
|
|
110
|
-
interface ReadHeadersOptions {
|
|
111
|
-
maxHeaderSize?: number;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Body reader that streams bytes with either a fixed Content-Length or until EOF.
|
|
116
|
-
*/
|
|
117
|
-
export declare class BodyReader implements IReadable, IClosable {
|
|
118
|
-
#private;
|
|
119
|
-
close: () => Promise<void> | void;
|
|
120
|
-
/**
|
|
121
|
-
* BodyReader configuration.
|
|
122
|
-
*
|
|
123
|
-
* @namespace BodyReader
|
|
124
|
-
*/
|
|
125
|
-
static Options: never;
|
|
126
|
-
constructor(src: Source, contentLength: number, opts?: BodyReader.Options);
|
|
127
|
-
read(into: Uint8Array): Promise<number>;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* BodyReader configuration.
|
|
131
|
-
*
|
|
132
|
-
* @namespace BodyReader
|
|
133
|
-
*/
|
|
134
|
-
export declare namespace BodyReader {
|
|
135
|
-
/**
|
|
136
|
-
* BodyReader instance options.
|
|
137
|
-
*
|
|
138
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
139
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
140
|
-
*
|
|
141
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
142
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
143
|
-
*
|
|
144
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
145
|
-
* Content-Encoding. Defaults to true.
|
|
146
|
-
*/
|
|
147
|
-
interface Options extends Readers.SizeLimitOptions, Readers.DecompressionOptions {
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* RFC 7230 chunked transfer-coding decoder.
|
|
152
|
-
*/
|
|
153
|
-
export declare class ChunkedBodyReader implements IReadable, IClosable {
|
|
154
|
-
#private;
|
|
155
|
-
close: () => Promise<void> | void;
|
|
156
|
-
/**
|
|
157
|
-
* ChunkedBodyReader configuration.
|
|
158
|
-
*
|
|
159
|
-
* @namespace ChunkedBodyReader
|
|
160
|
-
*/
|
|
161
|
-
static Options: never;
|
|
162
|
-
constructor(src: Source, opts?: ChunkedBodyReader.Options);
|
|
163
|
-
read(into: Uint8Array): Promise<number>;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* ChunkedBodyReader configuration.
|
|
167
|
-
*
|
|
168
|
-
* @namespace ChunkedBodyReader
|
|
169
|
-
*/
|
|
170
|
-
export declare namespace ChunkedBodyReader {
|
|
171
|
-
/**
|
|
172
|
-
* ChunkedBodyReader instance options.
|
|
173
|
-
*
|
|
174
|
-
* @property {number|string} [maxBodySize] - Maximum allowed entity-body size (raw, before content decoding).
|
|
175
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
176
|
-
*
|
|
177
|
-
* @property {number|string} [maxDecodedBodySize] - Maximum allowed decoded body size (after content decoding).
|
|
178
|
-
* Can be a number of bytes or a human-readable string like "10mb".
|
|
179
|
-
*
|
|
180
|
-
* @property {boolean} [decompress] - If true, the response body may be transparently decompressed based on
|
|
181
|
-
* Content-Encoding. Defaults to true.
|
|
182
|
-
*
|
|
183
|
-
* @property {number} [bufferSize] - Initial size (in bytes) for the internal buffer.
|
|
184
|
-
*
|
|
185
|
-
* @property {number} [highWaterMark] - Target read size (in bytes) for each pull from the underlying source.
|
|
186
|
-
* Defaults to 16 KiB.
|
|
187
|
-
*
|
|
188
|
-
* @property {number} [maxLineSize] - Maximum allowed bytes for CRLF-delimited chunk control lines.
|
|
189
|
-
* Defaults to 64 KiB.
|
|
190
|
-
*
|
|
191
|
-
* @property {number} [maxChunkSize] - Maximum allowed bytes for any single chunk.
|
|
192
|
-
* Defaults to 16 MiB.
|
|
193
|
-
*/
|
|
194
|
-
interface Options extends BodyReader.Options, Readers.BufferingOptions {
|
|
195
|
-
maxLineSize?: number;
|
|
196
|
-
maxChunkSize?: number;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
export {};
|