undici 6.21.0 → 7.0.0-alpha.10
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 +27 -46
- package/docs/docs/api/Agent.md +14 -17
- package/docs/docs/api/BalancedPool.md +16 -16
- package/docs/docs/api/CacheStore.md +131 -0
- package/docs/docs/api/Client.md +12 -14
- package/docs/docs/api/Debug.md +1 -1
- package/docs/docs/api/Dispatcher.md +98 -194
- package/docs/docs/api/EnvHttpProxyAgent.md +12 -13
- package/docs/docs/api/MockAgent.md +5 -3
- package/docs/docs/api/MockClient.md +5 -5
- package/docs/docs/api/MockPool.md +4 -3
- package/docs/docs/api/Pool.md +15 -16
- package/docs/docs/api/PoolStats.md +1 -1
- package/docs/docs/api/ProxyAgent.md +3 -3
- package/docs/docs/api/RedirectHandler.md +1 -1
- package/docs/docs/api/RetryAgent.md +1 -1
- package/docs/docs/api/RetryHandler.md +4 -4
- package/docs/docs/api/WebSocket.md +46 -4
- package/docs/docs/api/api-lifecycle.md +11 -11
- package/docs/docs/best-practices/mocking-request.md +2 -2
- package/docs/docs/best-practices/proxy.md +1 -1
- package/index.d.ts +1 -1
- package/index.js +23 -7
- package/lib/api/abort-signal.js +2 -0
- package/lib/api/api-connect.js +3 -1
- package/lib/api/api-pipeline.js +7 -6
- package/lib/api/api-request.js +33 -48
- package/lib/api/api-stream.js +39 -50
- package/lib/api/api-upgrade.js +5 -3
- package/lib/api/readable.js +235 -62
- package/lib/api/util.js +2 -0
- package/lib/cache/memory-cache-store.js +177 -0
- package/lib/cache/sqlite-cache-store.js +446 -0
- package/lib/core/constants.js +35 -10
- package/lib/core/diagnostics.js +122 -128
- package/lib/core/errors.js +6 -6
- package/lib/core/request.js +13 -11
- package/lib/core/symbols.js +2 -1
- package/lib/core/tree.js +9 -1
- package/lib/core/util.js +237 -49
- package/lib/dispatcher/agent.js +3 -17
- package/lib/dispatcher/balanced-pool.js +5 -8
- package/lib/dispatcher/client-h1.js +379 -134
- package/lib/dispatcher/client-h2.js +173 -107
- package/lib/dispatcher/client.js +19 -32
- package/lib/dispatcher/dispatcher-base.js +6 -35
- package/lib/dispatcher/dispatcher.js +7 -24
- package/lib/dispatcher/fixed-queue.js +91 -49
- package/lib/dispatcher/pool-stats.js +2 -0
- package/lib/dispatcher/pool.js +3 -6
- package/lib/dispatcher/proxy-agent.js +3 -6
- package/lib/handler/cache-handler.js +393 -0
- package/lib/handler/cache-revalidation-handler.js +124 -0
- package/lib/handler/decorator-handler.js +27 -0
- package/lib/handler/redirect-handler.js +54 -59
- package/lib/handler/retry-handler.js +77 -109
- package/lib/handler/unwrap-handler.js +96 -0
- package/lib/handler/wrap-handler.js +98 -0
- package/lib/interceptor/cache.js +350 -0
- package/lib/interceptor/dns.js +375 -0
- package/lib/interceptor/dump.js +2 -2
- package/lib/interceptor/redirect.js +11 -14
- package/lib/interceptor/response-error.js +18 -7
- 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-agent.js +5 -8
- package/lib/mock/mock-client.js +9 -4
- package/lib/mock/mock-errors.js +3 -1
- package/lib/mock/mock-interceptor.js +8 -6
- package/lib/mock/mock-pool.js +9 -4
- package/lib/mock/mock-symbols.js +3 -1
- package/lib/mock/mock-utils.js +29 -5
- package/lib/util/cache.js +360 -0
- package/lib/web/cache/cache.js +24 -21
- package/lib/web/cache/cachestorage.js +1 -1
- package/lib/web/cookies/index.js +29 -14
- package/lib/web/cookies/parse.js +8 -3
- package/lib/web/eventsource/eventsource-stream.js +9 -8
- package/lib/web/eventsource/eventsource.js +10 -6
- package/lib/web/fetch/body.js +43 -41
- package/lib/web/fetch/constants.js +12 -5
- package/lib/web/fetch/data-url.js +3 -3
- package/lib/web/fetch/formdata-parser.js +72 -45
- package/lib/web/fetch/formdata.js +65 -54
- package/lib/web/fetch/headers.js +118 -86
- package/lib/web/fetch/index.js +58 -67
- package/lib/web/fetch/request.js +136 -77
- package/lib/web/fetch/response.js +87 -56
- package/lib/web/fetch/util.js +259 -109
- package/lib/web/fetch/webidl.js +113 -68
- package/lib/web/websocket/connection.js +76 -147
- package/lib/web/websocket/constants.js +70 -10
- package/lib/web/websocket/events.js +4 -2
- package/lib/web/websocket/frame.js +45 -3
- package/lib/web/websocket/receiver.js +29 -33
- package/lib/web/websocket/sender.js +18 -13
- package/lib/web/websocket/stream/websocketerror.js +83 -0
- package/lib/web/websocket/stream/websocketstream.js +485 -0
- package/lib/web/websocket/util.js +128 -77
- package/lib/web/websocket/websocket.js +234 -135
- package/package.json +24 -36
- 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/cache-interceptor.d.ts +172 -0
- package/types/client.d.ts +11 -12
- package/types/cookies.d.ts +2 -0
- package/types/diagnostics-channel.d.ts +10 -10
- package/types/dispatcher.d.ts +113 -90
- package/types/env-http-proxy-agent.d.ts +2 -2
- package/types/errors.d.ts +53 -47
- package/types/fetch.d.ts +17 -16
- 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 +7 -7
- package/types/header.d.ts +157 -1
- package/types/index.d.ts +44 -46
- package/types/interceptors.d.ts +25 -8
- package/types/mock-agent.d.ts +21 -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 -4
- 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 +18 -15
- package/types/retry-agent.d.ts +1 -1
- package/types/retry-handler.d.ts +10 -10
- package/types/util.d.ts +3 -3
- package/types/utility.d.ts +7 -0
- package/types/webidl.d.ts +44 -6
- package/types/websocket.d.ts +34 -1
- package/docs/docs/api/DispatchInterceptor.md +0 -60
- package/lib/interceptor/redirect-interceptor.js +0 -21
- package/lib/mock/pluralizer.js +0 -29
- package/lib/web/cache/symbols.js +0 -5
- package/lib/web/fetch/file.js +0 -126
- package/lib/web/fetch/symbols.js +0 -9
- 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.
|
|
14
|
+
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): 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
|
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Readable, Writable } from 'node:stream'
|
|
2
|
+
|
|
3
|
+
export default CacheHandler
|
|
4
|
+
|
|
5
|
+
declare namespace CacheHandler {
|
|
6
|
+
export type CacheMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE'
|
|
7
|
+
|
|
8
|
+
export interface CacheHandlerOptions {
|
|
9
|
+
store: CacheStore
|
|
10
|
+
|
|
11
|
+
cacheByDefault?: number
|
|
12
|
+
|
|
13
|
+
type?: CacheOptions['type']
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CacheOptions {
|
|
17
|
+
store?: CacheStore
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The methods to cache
|
|
21
|
+
* Note we can only cache safe methods. Unsafe methods (i.e. PUT, POST)
|
|
22
|
+
* invalidate the cache for a origin.
|
|
23
|
+
* @see https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons
|
|
24
|
+
* @see https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1
|
|
25
|
+
*/
|
|
26
|
+
methods?: CacheMethods[]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* RFC9111 allows for caching responses that we aren't explicitly told to
|
|
30
|
+
* cache or to not cache.
|
|
31
|
+
* @see https://www.rfc-editor.org/rfc/rfc9111.html#section-3-5
|
|
32
|
+
* @default undefined
|
|
33
|
+
*/
|
|
34
|
+
cacheByDefault?: number
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* TODO docs
|
|
38
|
+
* @default 'shared'
|
|
39
|
+
*/
|
|
40
|
+
type?: 'shared' | 'private'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CacheControlDirectives {
|
|
44
|
+
'max-stale'?: number;
|
|
45
|
+
'min-fresh'?: number;
|
|
46
|
+
'max-age'?: number;
|
|
47
|
+
's-maxage'?: number;
|
|
48
|
+
'stale-while-revalidate'?: number;
|
|
49
|
+
'stale-if-error'?: number;
|
|
50
|
+
public?: true;
|
|
51
|
+
private?: true | string[];
|
|
52
|
+
'no-store'?: true;
|
|
53
|
+
'no-cache'?: true | string[];
|
|
54
|
+
'must-revalidate'?: true;
|
|
55
|
+
'proxy-revalidate'?: true;
|
|
56
|
+
immutable?: true;
|
|
57
|
+
'no-transform'?: true;
|
|
58
|
+
'must-understand'?: true;
|
|
59
|
+
'only-if-cached'?: true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CacheKey {
|
|
63
|
+
origin: string
|
|
64
|
+
method: string
|
|
65
|
+
path: string
|
|
66
|
+
headers?: Record<string, string | string[]>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CacheValue {
|
|
70
|
+
statusCode: number
|
|
71
|
+
statusMessage: string
|
|
72
|
+
headers: Record<string, string | string[]>
|
|
73
|
+
vary?: Record<string, string | string[]>
|
|
74
|
+
etag?: string
|
|
75
|
+
cacheControlDirectives?: CacheControlDirectives
|
|
76
|
+
cachedAt: number
|
|
77
|
+
staleAt: number
|
|
78
|
+
deleteAt: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface DeleteByUri {
|
|
82
|
+
origin: string
|
|
83
|
+
method: string
|
|
84
|
+
path: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type GetResult = {
|
|
88
|
+
statusCode: number
|
|
89
|
+
statusMessage: string
|
|
90
|
+
headers: Record<string, string | string[]>
|
|
91
|
+
vary?: Record<string, string | string[]>
|
|
92
|
+
etag?: string
|
|
93
|
+
body: null | Readable | Iterable<Buffer> | AsyncIterable<Buffer> | Buffer | Iterable<string> | AsyncIterable<string> | string
|
|
94
|
+
cacheControlDirectives: CacheControlDirectives,
|
|
95
|
+
cachedAt: number
|
|
96
|
+
staleAt: number
|
|
97
|
+
deleteAt: number
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Underlying storage provider for cached responses
|
|
102
|
+
*/
|
|
103
|
+
export interface CacheStore {
|
|
104
|
+
get(key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
105
|
+
|
|
106
|
+
createWriteStream(key: CacheKey, val: CacheValue): Writable | undefined
|
|
107
|
+
|
|
108
|
+
delete(key: CacheKey): void | Promise<void>
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface MemoryCacheStoreOpts {
|
|
112
|
+
/**
|
|
113
|
+
* @default Infinity
|
|
114
|
+
*/
|
|
115
|
+
maxCount?: number
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @default Infinity
|
|
119
|
+
*/
|
|
120
|
+
maxSize?: number
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @default Infinity
|
|
124
|
+
*/
|
|
125
|
+
maxEntrySize?: number
|
|
126
|
+
|
|
127
|
+
errorCallback?: (err: Error) => void
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class MemoryCacheStore implements CacheStore {
|
|
131
|
+
constructor (opts?: MemoryCacheStoreOpts)
|
|
132
|
+
|
|
133
|
+
get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
134
|
+
|
|
135
|
+
createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
|
|
136
|
+
|
|
137
|
+
delete (key: CacheKey): void | Promise<void>
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface SqliteCacheStoreOpts {
|
|
141
|
+
/**
|
|
142
|
+
* Location of the database
|
|
143
|
+
* @default ':memory:'
|
|
144
|
+
*/
|
|
145
|
+
location?: string
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @default Infinity
|
|
149
|
+
*/
|
|
150
|
+
maxCount?: number
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @default Infinity
|
|
154
|
+
*/
|
|
155
|
+
maxEntrySize?: number
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export class SqliteCacheStore implements CacheStore {
|
|
159
|
+
constructor (opts?: SqliteCacheStoreOpts)
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Closes the connection to the database
|
|
163
|
+
*/
|
|
164
|
+
close (): void
|
|
165
|
+
|
|
166
|
+
get (key: CacheKey): GetResult | Promise<GetResult | undefined> | undefined
|
|
167
|
+
|
|
168
|
+
createWriteStream (key: CacheKey, value: CacheValue): Writable | undefined
|
|
169
|
+
|
|
170
|
+
delete (key: CacheKey): void | Promise<void>
|
|
171
|
+
}
|
|
172
|
+
}
|
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
|
package/types/cookies.d.ts
CHANGED
|
@@ -26,3 +26,5 @@ export function getCookies (headers: Headers): Record<string, string>
|
|
|
26
26
|
export function getSetCookies (headers: Headers): Cookie[]
|
|
27
27
|
|
|
28
28
|
export function setCookie (headers: Headers, cookie: Cookie): void
|
|
29
|
+
|
|
30
|
+
export function parseCookie (cookie: string): Cookie | null
|
|
@@ -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
|
}
|