undici 6.19.8 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -9
- package/docs/docs/api/Agent.md +0 -3
- package/docs/docs/api/Client.md +0 -2
- package/docs/docs/api/Dispatcher.md +204 -6
- package/docs/docs/api/EnvHttpProxyAgent.md +0 -1
- package/docs/docs/api/Fetch.md +1 -0
- package/docs/docs/api/Pool.md +0 -1
- package/docs/docs/api/RetryHandler.md +1 -1
- package/index.js +0 -4
- package/lib/api/api-connect.js +3 -1
- package/lib/api/api-pipeline.js +3 -4
- package/lib/api/api-request.js +29 -46
- package/lib/api/api-stream.js +36 -49
- package/lib/api/api-upgrade.js +5 -3
- package/lib/api/readable.js +71 -27
- package/lib/core/connect.js +39 -24
- package/lib/core/errors.js +17 -4
- package/lib/core/request.js +7 -5
- package/lib/core/symbols.js +0 -1
- package/lib/core/tree.js +6 -0
- package/lib/core/util.js +1 -11
- package/lib/dispatcher/agent.js +3 -17
- package/lib/dispatcher/balanced-pool.js +5 -8
- package/lib/dispatcher/client-h1.js +44 -39
- package/lib/dispatcher/client.js +3 -27
- package/lib/dispatcher/dispatcher-base.js +2 -34
- package/lib/dispatcher/dispatcher.js +3 -24
- package/lib/dispatcher/pool.js +3 -6
- package/lib/dispatcher/proxy-agent.js +3 -6
- package/lib/handler/decorator-handler.js +24 -0
- package/lib/handler/redirect-handler.js +9 -0
- package/lib/handler/retry-handler.js +22 -3
- package/lib/interceptor/dump.js +2 -2
- package/lib/interceptor/redirect.js +11 -14
- package/lib/interceptor/response-error.js +89 -0
- package/lib/llhttp/constants.d.ts +97 -0
- package/lib/llhttp/constants.js +412 -192
- package/lib/llhttp/constants.js.map +1 -0
- package/lib/llhttp/llhttp-wasm.js +11 -1
- package/lib/llhttp/llhttp_simd-wasm.js +11 -1
- package/lib/llhttp/utils.d.ts +2 -0
- package/lib/llhttp/utils.js +9 -9
- package/lib/llhttp/utils.js.map +1 -0
- package/lib/mock/mock-client.js +2 -2
- package/lib/mock/mock-pool.js +2 -2
- package/lib/mock/mock-symbols.js +1 -0
- package/lib/util/timers.js +324 -44
- package/lib/web/cookies/index.js +15 -13
- package/lib/web/cookies/parse.js +2 -2
- package/lib/web/eventsource/eventsource-stream.js +9 -8
- package/lib/web/eventsource/eventsource.js +10 -6
- package/lib/web/fetch/body.js +4 -6
- package/lib/web/fetch/data-url.js +1 -1
- package/lib/web/fetch/formdata-parser.js +1 -2
- package/lib/web/fetch/formdata.js +28 -37
- package/lib/web/fetch/headers.js +1 -1
- package/lib/web/fetch/index.js +7 -8
- package/lib/web/fetch/request.js +7 -24
- package/lib/web/fetch/response.js +9 -22
- package/lib/web/fetch/symbols.js +0 -1
- package/lib/web/fetch/util.js +3 -12
- package/lib/web/fetch/webidl.js +73 -62
- package/lib/web/websocket/connection.js +26 -174
- package/lib/web/websocket/constants.js +1 -1
- package/lib/web/websocket/frame.js +45 -3
- package/lib/web/websocket/receiver.js +28 -26
- package/lib/web/websocket/sender.js +18 -13
- package/lib/web/websocket/util.js +20 -74
- package/lib/web/websocket/websocket.js +294 -70
- package/package.json +16 -29
- package/scripts/strip-comments.js +3 -1
- package/types/agent.d.ts +7 -7
- package/types/api.d.ts +24 -24
- package/types/balanced-pool.d.ts +11 -11
- package/types/client.d.ts +11 -12
- package/types/diagnostics-channel.d.ts +10 -10
- package/types/dispatcher.d.ts +96 -97
- package/types/env-http-proxy-agent.d.ts +2 -2
- package/types/errors.d.ts +53 -47
- package/types/eventsource.d.ts +0 -2
- package/types/fetch.d.ts +8 -8
- package/types/formdata.d.ts +7 -7
- package/types/global-dispatcher.d.ts +4 -4
- package/types/global-origin.d.ts +5 -5
- package/types/handlers.d.ts +4 -4
- package/types/header.d.ts +157 -1
- package/types/index.d.ts +42 -46
- package/types/interceptors.d.ts +10 -8
- package/types/mock-agent.d.ts +18 -18
- package/types/mock-client.d.ts +4 -4
- package/types/mock-errors.d.ts +3 -3
- package/types/mock-interceptor.d.ts +19 -19
- package/types/mock-pool.d.ts +4 -4
- package/types/patch.d.ts +0 -42
- package/types/pool-stats.d.ts +8 -8
- package/types/pool.d.ts +12 -12
- package/types/proxy-agent.d.ts +4 -4
- package/types/readable.d.ts +14 -9
- package/types/retry-agent.d.ts +1 -1
- package/types/retry-handler.d.ts +8 -8
- package/types/util.d.ts +3 -3
- package/types/utility.d.ts +7 -0
- package/types/webidl.d.ts +22 -4
- package/types/websocket.d.ts +1 -3
- package/docs/docs/api/DispatchInterceptor.md +0 -60
- package/lib/interceptor/redirect-interceptor.js +0 -21
- package/lib/web/fetch/file.js +0 -126
- package/lib/web/fileapi/encoding.js +0 -290
- package/lib/web/fileapi/filereader.js +0 -344
- package/lib/web/fileapi/progressevent.js +0 -78
- package/lib/web/fileapi/symbols.js +0 -10
- package/lib/web/fileapi/util.js +0 -391
- package/lib/web/websocket/symbols.js +0 -12
- package/types/file.d.ts +0 -39
- package/types/filereader.d.ts +0 -54
package/types/agent.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { URL } from 'url'
|
|
2
2
|
import Pool from './pool'
|
|
3
|
-
import Dispatcher from
|
|
3
|
+
import Dispatcher from './dispatcher'
|
|
4
4
|
|
|
5
5
|
export default Agent
|
|
6
6
|
|
|
7
|
-
declare class Agent extends Dispatcher{
|
|
8
|
-
constructor(opts?: Agent.Options)
|
|
7
|
+
declare class Agent extends Dispatcher {
|
|
8
|
+
constructor (opts?: Agent.Options)
|
|
9
9
|
/** `true` after `dispatcher.close()` has been called. */
|
|
10
|
-
closed: boolean
|
|
10
|
+
closed: boolean
|
|
11
11
|
/** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
|
|
12
|
-
destroyed: boolean
|
|
12
|
+
destroyed: boolean
|
|
13
13
|
/** Dispatches a request. */
|
|
14
|
-
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
14
|
+
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare namespace Agent {
|
|
@@ -21,7 +21,7 @@ declare namespace Agent {
|
|
|
21
21
|
/** Integer. Default: `0` */
|
|
22
22
|
maxRedirections?: number;
|
|
23
23
|
|
|
24
|
-
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options[
|
|
24
|
+
interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface DispatchOptions extends Dispatcher.DispatchOptions {
|
package/types/api.d.ts
CHANGED
|
@@ -2,42 +2,42 @@ import { URL, UrlObject } from 'url'
|
|
|
2
2
|
import { Duplex } from 'stream'
|
|
3
3
|
import Dispatcher from './dispatcher'
|
|
4
4
|
|
|
5
|
-
export {
|
|
6
|
-
request,
|
|
7
|
-
stream,
|
|
8
|
-
pipeline,
|
|
9
|
-
connect,
|
|
10
|
-
upgrade,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
5
|
/** Performs an HTTP request. */
|
|
14
|
-
declare function request(
|
|
6
|
+
declare function request<TOpaque = null> (
|
|
15
7
|
url: string | URL | UrlObject,
|
|
16
|
-
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions
|
|
17
|
-
): Promise<Dispatcher.ResponseData
|
|
8
|
+
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
|
|
9
|
+
): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
18
10
|
|
|
19
11
|
/** A faster version of `request`. */
|
|
20
|
-
declare function stream(
|
|
12
|
+
declare function stream<TOpaque = null> (
|
|
21
13
|
url: string | URL | UrlObject,
|
|
22
|
-
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions
|
|
23
|
-
factory: Dispatcher.StreamFactory
|
|
24
|
-
): Promise<Dispatcher.StreamData
|
|
14
|
+
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
|
|
15
|
+
factory: Dispatcher.StreamFactory<TOpaque>
|
|
16
|
+
): Promise<Dispatcher.StreamData<TOpaque>>
|
|
25
17
|
|
|
26
18
|
/** For easy use with `stream.pipeline`. */
|
|
27
|
-
declare function pipeline(
|
|
19
|
+
declare function pipeline<TOpaque = null> (
|
|
28
20
|
url: string | URL | UrlObject,
|
|
29
|
-
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions
|
|
30
|
-
handler: Dispatcher.PipelineHandler
|
|
31
|
-
): Duplex
|
|
21
|
+
options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
|
|
22
|
+
handler: Dispatcher.PipelineHandler<TOpaque>
|
|
23
|
+
): Duplex
|
|
32
24
|
|
|
33
25
|
/** Starts two-way communications with the requested resource. */
|
|
34
|
-
declare function connect(
|
|
26
|
+
declare function connect<TOpaque = null> (
|
|
35
27
|
url: string | URL | UrlObject,
|
|
36
|
-
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions
|
|
37
|
-
): Promise<Dispatcher.ConnectData
|
|
28
|
+
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
|
|
29
|
+
): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
38
30
|
|
|
39
31
|
/** Upgrade to a different protocol. */
|
|
40
|
-
declare function upgrade(
|
|
32
|
+
declare function upgrade (
|
|
41
33
|
url: string | URL | UrlObject,
|
|
42
34
|
options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
|
|
43
|
-
): Promise<Dispatcher.UpgradeData
|
|
35
|
+
): Promise<Dispatcher.UpgradeData>
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
request,
|
|
39
|
+
stream,
|
|
40
|
+
pipeline,
|
|
41
|
+
connect,
|
|
42
|
+
upgrade
|
|
43
|
+
}
|
package/types/balanced-pool.d.ts
CHANGED
|
@@ -4,26 +4,26 @@ import { URL } from 'url'
|
|
|
4
4
|
|
|
5
5
|
export default BalancedPool
|
|
6
6
|
|
|
7
|
-
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions,
|
|
7
|
+
type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
|
|
8
8
|
|
|
9
9
|
declare class BalancedPool extends Dispatcher {
|
|
10
|
-
constructor(url: string | string[] | URL | URL[], options?: Pool.Options)
|
|
10
|
+
constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
|
|
11
11
|
|
|
12
|
-
addUpstream(upstream: string | URL): BalancedPool
|
|
13
|
-
removeUpstream(upstream: string | URL): BalancedPool
|
|
14
|
-
upstreams: Array<string
|
|
12
|
+
addUpstream (upstream: string | URL): BalancedPool
|
|
13
|
+
removeUpstream (upstream: string | URL): BalancedPool
|
|
14
|
+
upstreams: Array<string>
|
|
15
15
|
|
|
16
16
|
/** `true` after `pool.close()` has been called. */
|
|
17
|
-
closed: boolean
|
|
17
|
+
closed: boolean
|
|
18
18
|
/** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
|
|
19
|
-
destroyed: boolean
|
|
19
|
+
destroyed: boolean
|
|
20
20
|
|
|
21
21
|
// Override dispatcher APIs.
|
|
22
|
-
override connect(
|
|
22
|
+
override connect (
|
|
23
23
|
options: BalancedPoolConnectOptions
|
|
24
|
-
): Promise<Dispatcher.ConnectData
|
|
25
|
-
override connect(
|
|
24
|
+
): Promise<Dispatcher.ConnectData>
|
|
25
|
+
override connect (
|
|
26
26
|
options: BalancedPoolConnectOptions,
|
|
27
27
|
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
|
28
|
-
): void
|
|
28
|
+
): void
|
|
29
29
|
}
|
package/types/client.d.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { URL } from 'url'
|
|
2
|
-
import { TlsOptions } from 'tls'
|
|
3
2
|
import Dispatcher from './dispatcher'
|
|
4
|
-
import buildConnector from
|
|
3
|
+
import buildConnector from './connector'
|
|
5
4
|
|
|
6
|
-
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions,
|
|
5
|
+
type ClientConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
|
|
10
9
|
*/
|
|
11
10
|
export class Client extends Dispatcher {
|
|
12
|
-
constructor(url: string | URL, options?: Client.Options)
|
|
11
|
+
constructor (url: string | URL, options?: Client.Options)
|
|
13
12
|
/** Property to get and set the pipelining factor. */
|
|
14
|
-
pipelining: number
|
|
13
|
+
pipelining: number
|
|
15
14
|
/** `true` after `client.close()` has been called. */
|
|
16
|
-
closed: boolean
|
|
15
|
+
closed: boolean
|
|
17
16
|
/** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
|
|
18
|
-
destroyed: boolean
|
|
17
|
+
destroyed: boolean
|
|
19
18
|
|
|
20
19
|
// Override dispatcher APIs.
|
|
21
|
-
override connect(
|
|
20
|
+
override connect (
|
|
22
21
|
options: ClientConnectOptions
|
|
23
|
-
): Promise<Dispatcher.ConnectData
|
|
24
|
-
override connect(
|
|
22
|
+
): Promise<Dispatcher.ConnectData>
|
|
23
|
+
override connect (
|
|
25
24
|
options: ClientConnectOptions,
|
|
26
25
|
callback: (err: Error | null, data: Dispatcher.ConnectData) => void
|
|
27
|
-
): void
|
|
26
|
+
): void
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export declare namespace Client {
|
|
@@ -105,4 +104,4 @@ export declare namespace Client {
|
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
export default Client
|
|
107
|
+
export default Client
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Socket } from
|
|
2
|
-
import { URL } from
|
|
3
|
-
import
|
|
4
|
-
import Dispatcher from
|
|
1
|
+
import { Socket } from 'net'
|
|
2
|
+
import { URL } from 'url'
|
|
3
|
+
import buildConnector from './connector'
|
|
4
|
+
import Dispatcher from './dispatcher'
|
|
5
5
|
|
|
6
6
|
declare namespace DiagnosticsChannel {
|
|
7
7
|
interface Request {
|
|
@@ -16,15 +16,15 @@ declare namespace DiagnosticsChannel {
|
|
|
16
16
|
statusText: string;
|
|
17
17
|
headers: Array<Buffer>;
|
|
18
18
|
}
|
|
19
|
-
type Error = unknown
|
|
19
|
+
type Error = unknown
|
|
20
20
|
interface ConnectParams {
|
|
21
|
-
host: URL[
|
|
22
|
-
hostname: URL[
|
|
23
|
-
protocol: URL[
|
|
24
|
-
port: URL[
|
|
21
|
+
host: URL['host'];
|
|
22
|
+
hostname: URL['hostname'];
|
|
23
|
+
protocol: URL['protocol'];
|
|
24
|
+
port: URL['port'];
|
|
25
25
|
servername: string | null;
|
|
26
26
|
}
|
|
27
|
-
type Connector =
|
|
27
|
+
type Connector = buildConnector.connector
|
|
28
28
|
export interface RequestCreateMessage {
|
|
29
29
|
request: Request;
|
|
30
30
|
}
|
package/types/dispatcher.d.ts
CHANGED
|
@@ -6,98 +6,96 @@ import { IncomingHttpHeaders } from './header'
|
|
|
6
6
|
import BodyReadable from './readable'
|
|
7
7
|
import { FormData } from './formdata'
|
|
8
8
|
import Errors from './errors'
|
|
9
|
+
import { Autocomplete } from './utility'
|
|
9
10
|
|
|
10
|
-
type AbortSignal = unknown
|
|
11
|
+
type AbortSignal = unknown
|
|
11
12
|
|
|
12
13
|
export default Dispatcher
|
|
13
14
|
|
|
14
15
|
/** Dispatcher is the core API used to dispatch requests. */
|
|
15
16
|
declare class Dispatcher extends EventEmitter {
|
|
16
17
|
/** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
|
|
17
|
-
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
18
|
+
dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
18
19
|
/** Starts two-way communications with the requested resource. */
|
|
19
|
-
connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData
|
|
20
|
-
connect(options: Dispatcher.ConnectOptions
|
|
20
|
+
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>
|
|
21
|
+
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void
|
|
21
22
|
/** Compose a chain of dispatchers */
|
|
22
|
-
compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
23
|
-
compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
23
|
+
compose (dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
24
|
+
compose (...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher
|
|
24
25
|
/** Performs an HTTP request. */
|
|
25
|
-
request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData
|
|
26
|
-
request(options: Dispatcher.RequestOptions
|
|
26
|
+
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>
|
|
27
|
+
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void
|
|
27
28
|
/** For easy use with `stream.pipeline`. */
|
|
28
|
-
pipeline(options: Dispatcher.PipelineOptions
|
|
29
|
+
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex
|
|
29
30
|
/** A faster version of `Dispatcher.request`. */
|
|
30
|
-
stream(options: Dispatcher.RequestOptions
|
|
31
|
-
stream(options: Dispatcher.RequestOptions
|
|
31
|
+
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>
|
|
32
|
+
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void
|
|
32
33
|
/** Upgrade to a different protocol. */
|
|
33
|
-
upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData
|
|
34
|
-
upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
|
|
34
|
+
upgrade (options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>
|
|
35
|
+
upgrade (options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void
|
|
35
36
|
/** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
|
|
36
|
-
close(): Promise<void
|
|
37
|
-
close(callback: () => void): void
|
|
37
|
+
close (): Promise<void>
|
|
38
|
+
close (callback: () => void): void
|
|
38
39
|
/** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
|
|
39
|
-
destroy(): Promise<void
|
|
40
|
-
destroy(err: Error | null): Promise<void
|
|
41
|
-
destroy(callback: () => void): void
|
|
42
|
-
destroy(err: Error | null, callback: () => void): void
|
|
43
|
-
|
|
44
|
-
on(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
45
|
-
on(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
46
|
-
on(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
47
|
-
on(eventName: 'drain', callback: (origin: URL) => void): this
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
once(eventName: '
|
|
51
|
-
once(eventName: '
|
|
52
|
-
once(eventName: '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
off(eventName: '
|
|
57
|
-
off(eventName: '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
addListener(eventName: '
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
removeListener(eventName: '
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
prependListener(eventName: '
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
prependOnceListener(eventName: '
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
listeners(eventName: '
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
rawListeners(eventName: '
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
emit(eventName: '
|
|
93
|
-
emit(eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
94
|
-
emit(eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
95
|
-
emit(eventName: 'drain', origin: URL): boolean;
|
|
40
|
+
destroy (): Promise<void>
|
|
41
|
+
destroy (err: Error | null): Promise<void>
|
|
42
|
+
destroy (callback: () => void): void
|
|
43
|
+
destroy (err: Error | null, callback: () => void): void
|
|
44
|
+
|
|
45
|
+
on (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
46
|
+
on (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
47
|
+
on (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
48
|
+
on (eventName: 'drain', callback: (origin: URL) => void): this
|
|
49
|
+
|
|
50
|
+
once (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
51
|
+
once (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
52
|
+
once (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
53
|
+
once (eventName: 'drain', callback: (origin: URL) => void): this
|
|
54
|
+
|
|
55
|
+
off (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
56
|
+
off (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
57
|
+
off (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
58
|
+
off (eventName: 'drain', callback: (origin: URL) => void): this
|
|
59
|
+
|
|
60
|
+
addListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
61
|
+
addListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
62
|
+
addListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
63
|
+
addListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
64
|
+
|
|
65
|
+
removeListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
66
|
+
removeListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
67
|
+
removeListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
68
|
+
removeListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
69
|
+
|
|
70
|
+
prependListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
71
|
+
prependListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
72
|
+
prependListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
73
|
+
prependListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
74
|
+
|
|
75
|
+
prependOnceListener (eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this
|
|
76
|
+
prependOnceListener (eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
77
|
+
prependOnceListener (eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this
|
|
78
|
+
prependOnceListener (eventName: 'drain', callback: (origin: URL) => void): this
|
|
79
|
+
|
|
80
|
+
listeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
81
|
+
listeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
82
|
+
listeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
83
|
+
listeners (eventName: 'drain'): ((origin: URL) => void)[]
|
|
84
|
+
|
|
85
|
+
rawListeners (eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[]
|
|
86
|
+
rawListeners (eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
87
|
+
rawListeners (eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[]
|
|
88
|
+
rawListeners (eventName: 'drain'): ((origin: URL) => void)[]
|
|
89
|
+
|
|
90
|
+
emit (eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean
|
|
91
|
+
emit (eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
92
|
+
emit (eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean
|
|
93
|
+
emit (eventName: 'drain', origin: URL): boolean
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
declare namespace Dispatcher {
|
|
99
97
|
export interface ComposedDispatcher extends Dispatcher {}
|
|
100
|
-
export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
|
|
98
|
+
export type DispatcherComposeInterceptor = (dispatch: Dispatcher['dispatch']) => Dispatcher['dispatch']
|
|
101
99
|
export interface DispatchOptions {
|
|
102
100
|
origin?: string | URL;
|
|
103
101
|
path: string;
|
|
@@ -122,10 +120,10 @@ declare namespace Dispatcher {
|
|
|
122
120
|
reset?: boolean;
|
|
123
121
|
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
|
|
124
122
|
throwOnError?: boolean;
|
|
125
|
-
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server*/
|
|
123
|
+
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
|
|
126
124
|
expectContinue?: boolean;
|
|
127
125
|
}
|
|
128
|
-
export interface ConnectOptions {
|
|
126
|
+
export interface ConnectOptions<TOpaque = null> {
|
|
129
127
|
origin: string | URL;
|
|
130
128
|
path: string;
|
|
131
129
|
/** Default: `null` */
|
|
@@ -133,17 +131,17 @@ declare namespace Dispatcher {
|
|
|
133
131
|
/** Default: `null` */
|
|
134
132
|
signal?: AbortSignal | EventEmitter | null;
|
|
135
133
|
/** This argument parameter is passed through to `ConnectData` */
|
|
136
|
-
opaque?:
|
|
134
|
+
opaque?: TOpaque;
|
|
137
135
|
/** Default: 0 */
|
|
138
136
|
maxRedirections?: number;
|
|
139
137
|
/** Default: false */
|
|
140
138
|
redirectionLimitReached?: boolean;
|
|
141
139
|
/** Default: `null` */
|
|
142
|
-
|
|
140
|
+
responseHeaders?: 'raw' | null;
|
|
143
141
|
}
|
|
144
|
-
export interface RequestOptions extends DispatchOptions {
|
|
142
|
+
export interface RequestOptions<TOpaque = null> extends DispatchOptions {
|
|
145
143
|
/** Default: `null` */
|
|
146
|
-
opaque?:
|
|
144
|
+
opaque?: TOpaque;
|
|
147
145
|
/** Default: `null` */
|
|
148
146
|
signal?: AbortSignal | EventEmitter | null;
|
|
149
147
|
/** Default: 0 */
|
|
@@ -153,11 +151,11 @@ declare namespace Dispatcher {
|
|
|
153
151
|
/** Default: `null` */
|
|
154
152
|
onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
|
|
155
153
|
/** Default: `null` */
|
|
156
|
-
|
|
154
|
+
responseHeaders?: 'raw' | null;
|
|
157
155
|
/** Default: `64 KiB` */
|
|
158
156
|
highWaterMark?: number;
|
|
159
157
|
}
|
|
160
|
-
export interface PipelineOptions extends RequestOptions {
|
|
158
|
+
export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
|
|
161
159
|
/** `true` if the `handler` will return an object stream. Default: `false` */
|
|
162
160
|
objectMode?: boolean;
|
|
163
161
|
}
|
|
@@ -176,45 +174,45 @@ declare namespace Dispatcher {
|
|
|
176
174
|
/** Default: false */
|
|
177
175
|
redirectionLimitReached?: boolean;
|
|
178
176
|
/** Default: `null` */
|
|
179
|
-
|
|
177
|
+
responseHeaders?: 'raw' | null;
|
|
180
178
|
}
|
|
181
|
-
export interface ConnectData {
|
|
179
|
+
export interface ConnectData<TOpaque = null> {
|
|
182
180
|
statusCode: number;
|
|
183
181
|
headers: IncomingHttpHeaders;
|
|
184
182
|
socket: Duplex;
|
|
185
|
-
opaque:
|
|
183
|
+
opaque: TOpaque;
|
|
186
184
|
}
|
|
187
|
-
export interface ResponseData {
|
|
185
|
+
export interface ResponseData<TOpaque = null> {
|
|
188
186
|
statusCode: number;
|
|
189
187
|
headers: IncomingHttpHeaders;
|
|
190
188
|
body: BodyReadable & BodyMixin;
|
|
191
189
|
trailers: Record<string, string>;
|
|
192
|
-
opaque:
|
|
190
|
+
opaque: TOpaque;
|
|
193
191
|
context: object;
|
|
194
192
|
}
|
|
195
|
-
export interface PipelineHandlerData {
|
|
193
|
+
export interface PipelineHandlerData<TOpaque = null> {
|
|
196
194
|
statusCode: number;
|
|
197
195
|
headers: IncomingHttpHeaders;
|
|
198
|
-
opaque:
|
|
196
|
+
opaque: TOpaque;
|
|
199
197
|
body: BodyReadable;
|
|
200
198
|
context: object;
|
|
201
199
|
}
|
|
202
|
-
export interface StreamData {
|
|
203
|
-
opaque:
|
|
200
|
+
export interface StreamData<TOpaque = null> {
|
|
201
|
+
opaque: TOpaque;
|
|
204
202
|
trailers: Record<string, string>;
|
|
205
203
|
}
|
|
206
|
-
export interface UpgradeData {
|
|
204
|
+
export interface UpgradeData<TOpaque = null> {
|
|
207
205
|
headers: IncomingHttpHeaders;
|
|
208
206
|
socket: Duplex;
|
|
209
|
-
opaque:
|
|
207
|
+
opaque: TOpaque;
|
|
210
208
|
}
|
|
211
|
-
export interface StreamFactoryData {
|
|
209
|
+
export interface StreamFactoryData<TOpaque = null> {
|
|
212
210
|
statusCode: number;
|
|
213
211
|
headers: IncomingHttpHeaders;
|
|
214
|
-
opaque:
|
|
212
|
+
opaque: TOpaque;
|
|
215
213
|
context: object;
|
|
216
214
|
}
|
|
217
|
-
export type StreamFactory = (data: StreamFactoryData) => Writable
|
|
215
|
+
export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable
|
|
218
216
|
export interface DispatchHandlers {
|
|
219
217
|
/** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
|
|
220
218
|
onConnect?(abort: (err?: Error) => void): void;
|
|
@@ -233,8 +231,8 @@ declare namespace Dispatcher {
|
|
|
233
231
|
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
|
|
234
232
|
onBodySent?(chunkSize: number, totalBytesSent: number): void;
|
|
235
233
|
}
|
|
236
|
-
export type PipelineHandler = (data: PipelineHandlerData) => Readable
|
|
237
|
-
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'
|
|
234
|
+
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable
|
|
235
|
+
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>
|
|
238
236
|
|
|
239
237
|
/**
|
|
240
238
|
* @link https://fetch.spec.whatwg.org/#body-mixin
|
|
@@ -244,6 +242,7 @@ declare namespace Dispatcher {
|
|
|
244
242
|
readonly bodyUsed: boolean;
|
|
245
243
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
246
244
|
blob(): Promise<Blob>;
|
|
245
|
+
bytes(): Promise<Uint8Array>;
|
|
247
246
|
formData(): Promise<never>;
|
|
248
247
|
json(): Promise<unknown>;
|
|
249
248
|
text(): Promise<string>;
|
|
@@ -4,9 +4,9 @@ import Dispatcher from './dispatcher'
|
|
|
4
4
|
export default EnvHttpProxyAgent
|
|
5
5
|
|
|
6
6
|
declare class EnvHttpProxyAgent extends Dispatcher {
|
|
7
|
-
constructor(opts?: EnvHttpProxyAgent.Options)
|
|
7
|
+
constructor (opts?: EnvHttpProxyAgent.Options)
|
|
8
8
|
|
|
9
|
-
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
9
|
+
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare namespace EnvHttpProxyAgent {
|