undici 7.0.0-alpha.4 → 7.0.0-alpha.5
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/docs/docs/api/Agent.md +14 -14
- package/docs/docs/api/BalancedPool.md +15 -15
- package/docs/docs/api/CacheStore.md +22 -3
- package/docs/docs/api/Client.md +11 -11
- package/docs/docs/api/Dispatcher.md +8 -8
- package/docs/docs/api/EnvHttpProxyAgent.md +12 -12
- package/docs/docs/api/MockAgent.md +3 -3
- package/docs/docs/api/MockClient.md +4 -4
- package/docs/docs/api/MockPool.md +2 -2
- package/docs/docs/api/Pool.md +14 -14
- package/docs/docs/api/PoolStats.md +1 -1
- package/docs/docs/api/ProxyAgent.md +3 -3
- package/docs/docs/api/RetryHandler.md +2 -2
- package/docs/docs/api/WebSocket.md +1 -1
- package/docs/docs/api/api-lifecycle.md +9 -9
- package/lib/cache/memory-cache-store.js +86 -230
- package/lib/handler/cache-handler.js +16 -5
- package/lib/interceptor/cache.js +119 -19
- package/lib/util/cache.js +35 -0
- package/lib/util/timers.js +19 -1
- package/package.json +1 -1
- package/types/cache-interceptor.d.ts +27 -34
package/docs/docs/api/Agent.md
CHANGED
|
@@ -16,7 +16,7 @@ Returns: `Agent`
|
|
|
16
16
|
|
|
17
17
|
### Parameter: `AgentOptions`
|
|
18
18
|
|
|
19
|
-
Extends: [`PoolOptions`](Pool.md#parameter-pooloptions)
|
|
19
|
+
Extends: [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions)
|
|
20
20
|
|
|
21
21
|
* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
|
|
22
22
|
|
|
@@ -24,54 +24,54 @@ Extends: [`PoolOptions`](Pool.md#parameter-pooloptions)
|
|
|
24
24
|
|
|
25
25
|
### `Agent.closed`
|
|
26
26
|
|
|
27
|
-
Implements [Client.closed](Client.md#clientclosed)
|
|
27
|
+
Implements [Client.closed](/docs/docs/api/Client.md#clientclosed)
|
|
28
28
|
|
|
29
29
|
### `Agent.destroyed`
|
|
30
30
|
|
|
31
|
-
Implements [Client.destroyed](Client.md#clientdestroyed)
|
|
31
|
+
Implements [Client.destroyed](/docs/docs/api/Client.md#clientdestroyed)
|
|
32
32
|
|
|
33
33
|
## Instance Methods
|
|
34
34
|
|
|
35
35
|
### `Agent.close([callback])`
|
|
36
36
|
|
|
37
|
-
Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
|
37
|
+
Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
|
|
38
38
|
|
|
39
39
|
### `Agent.destroy([error, callback])`
|
|
40
40
|
|
|
41
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
41
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
42
42
|
|
|
43
43
|
### `Agent.dispatch(options, handler: AgentDispatchOptions)`
|
|
44
44
|
|
|
45
|
-
Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
45
|
+
Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
46
46
|
|
|
47
47
|
#### Parameter: `AgentDispatchOptions`
|
|
48
48
|
|
|
49
|
-
Extends: [`DispatchOptions`](Dispatcher.md#parameter-dispatchoptions)
|
|
49
|
+
Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)
|
|
50
50
|
|
|
51
51
|
* **origin** `string | URL`
|
|
52
52
|
|
|
53
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
53
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
54
54
|
|
|
55
55
|
### `Agent.connect(options[, callback])`
|
|
56
56
|
|
|
57
|
-
See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
|
57
|
+
See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
|
|
58
58
|
|
|
59
59
|
### `Agent.dispatch(options, handler)`
|
|
60
60
|
|
|
61
|
-
Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
61
|
+
Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
62
62
|
|
|
63
63
|
### `Agent.pipeline(options, handler)`
|
|
64
64
|
|
|
65
|
-
See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
65
|
+
See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
66
66
|
|
|
67
67
|
### `Agent.request(options[, callback])`
|
|
68
68
|
|
|
69
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
69
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
70
70
|
|
|
71
71
|
### `Agent.stream(options, factory[, callback])`
|
|
72
72
|
|
|
73
|
-
See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
73
|
+
See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
74
74
|
|
|
75
75
|
### `Agent.upgrade(options[, callback])`
|
|
76
76
|
|
|
77
|
-
See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
77
|
+
See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
@@ -15,7 +15,7 @@ Arguments:
|
|
|
15
15
|
|
|
16
16
|
### Parameter: `BalancedPoolOptions`
|
|
17
17
|
|
|
18
|
-
Extends: [`PoolOptions`](Pool.md#parameter-pooloptions)
|
|
18
|
+
Extends: [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions)
|
|
19
19
|
|
|
20
20
|
* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
|
|
21
21
|
|
|
@@ -28,15 +28,15 @@ Returns an array of upstreams that were previously added.
|
|
|
28
28
|
|
|
29
29
|
### `BalancedPool.closed`
|
|
30
30
|
|
|
31
|
-
Implements [Client.closed](Client.md#clientclosed)
|
|
31
|
+
Implements [Client.closed](/docs/docs/api/Client.md#clientclosed)
|
|
32
32
|
|
|
33
33
|
### `BalancedPool.destroyed`
|
|
34
34
|
|
|
35
|
-
Implements [Client.destroyed](Client.md#clientdestroyed)
|
|
35
|
+
Implements [Client.destroyed](/docs/docs/api/Client.md#clientdestroyed)
|
|
36
36
|
|
|
37
37
|
### `Pool.stats`
|
|
38
38
|
|
|
39
|
-
Returns [`PoolStats`](PoolStats.md) instance for this pool.
|
|
39
|
+
Returns [`PoolStats`](/docs/docs/api/PoolStats.md) instance for this pool.
|
|
40
40
|
|
|
41
41
|
## Instance Methods
|
|
42
42
|
|
|
@@ -54,46 +54,46 @@ Removes an upstream that was previously added.
|
|
|
54
54
|
|
|
55
55
|
### `BalancedPool.close([callback])`
|
|
56
56
|
|
|
57
|
-
Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
|
57
|
+
Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
|
|
58
58
|
|
|
59
59
|
### `BalancedPool.destroy([error, callback])`
|
|
60
60
|
|
|
61
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
61
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
62
62
|
|
|
63
63
|
### `BalancedPool.connect(options[, callback])`
|
|
64
64
|
|
|
65
|
-
See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
|
65
|
+
See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
|
|
66
66
|
|
|
67
67
|
### `BalancedPool.dispatch(options, handlers)`
|
|
68
68
|
|
|
69
|
-
Implements [`Dispatcher.dispatch(options, handlers)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
69
|
+
Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
70
70
|
|
|
71
71
|
### `BalancedPool.pipeline(options, handler)`
|
|
72
72
|
|
|
73
|
-
See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
73
|
+
See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
74
74
|
|
|
75
75
|
### `BalancedPool.request(options[, callback])`
|
|
76
76
|
|
|
77
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
77
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
78
78
|
|
|
79
79
|
### `BalancedPool.stream(options, factory[, callback])`
|
|
80
80
|
|
|
81
|
-
See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
81
|
+
See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
82
82
|
|
|
83
83
|
### `BalancedPool.upgrade(options[, callback])`
|
|
84
84
|
|
|
85
|
-
See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
85
|
+
See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
86
86
|
|
|
87
87
|
## Instance Events
|
|
88
88
|
|
|
89
89
|
### Event: `'connect'`
|
|
90
90
|
|
|
91
|
-
See [Dispatcher Event: `'connect'`](Dispatcher.md#event-connect).
|
|
91
|
+
See [Dispatcher Event: `'connect'`](/docs/docs/api/Dispatcher.md#event-connect).
|
|
92
92
|
|
|
93
93
|
### Event: `'disconnect'`
|
|
94
94
|
|
|
95
|
-
See [Dispatcher Event: `'disconnect'`](Dispatcher.md#event-disconnect).
|
|
95
|
+
See [Dispatcher Event: `'disconnect'`](/docs/docs/api/Dispatcher.md#event-disconnect).
|
|
96
96
|
|
|
97
97
|
### Event: `'drain'`
|
|
98
98
|
|
|
99
|
-
See [Dispatcher Event: `'drain'`](Dispatcher.md#event-drain).
|
|
99
|
+
See [Dispatcher Event: `'drain'`](/docs/docs/api/Dispatcher.md#event-drain).
|
|
@@ -36,7 +36,7 @@ If the request isn't cached, `undefined` is returned.
|
|
|
36
36
|
|
|
37
37
|
Response properties:
|
|
38
38
|
|
|
39
|
-
* **response** `
|
|
39
|
+
* **response** `CacheValue` - The cached response data.
|
|
40
40
|
* **body** `Readable | undefined` - The response's body.
|
|
41
41
|
|
|
42
42
|
### Function: `createWriteStream`
|
|
@@ -44,11 +44,11 @@ Response properties:
|
|
|
44
44
|
Parameters:
|
|
45
45
|
|
|
46
46
|
* **req** `Dispatcher.RequestOptions` - Incoming request
|
|
47
|
-
* **value** `
|
|
47
|
+
* **value** `CacheValue` - Response to store
|
|
48
48
|
|
|
49
49
|
Returns: `Writable | undefined` - If the store is full, return `undefined`. Otherwise, return a writable so that the cache interceptor can stream the body and trailers to the store.
|
|
50
50
|
|
|
51
|
-
## `
|
|
51
|
+
## `CacheValue`
|
|
52
52
|
|
|
53
53
|
This is an interface containing the majority of a response's data (minus the body).
|
|
54
54
|
|
|
@@ -98,3 +98,22 @@ This would be
|
|
|
98
98
|
is either the same sa staleAt or the `max-stale` caching directive.
|
|
99
99
|
|
|
100
100
|
The store must not return a response after the time defined in this property.
|
|
101
|
+
|
|
102
|
+
## `CacheStoreReadable`
|
|
103
|
+
|
|
104
|
+
This extends Node's [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable)
|
|
105
|
+
and defines extra properties relevant to the cache interceptor.
|
|
106
|
+
|
|
107
|
+
### Getter: `value`
|
|
108
|
+
|
|
109
|
+
The response's [`CacheStoreValue`](/docs/docs/api/CacheStore.md#cachestorevalue)
|
|
110
|
+
|
|
111
|
+
## `CacheStoreWriteable`
|
|
112
|
+
|
|
113
|
+
This extends Node's [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable)
|
|
114
|
+
and defines extra properties relevant to the cache interceptor.
|
|
115
|
+
|
|
116
|
+
### Setter: `rawTrailers`
|
|
117
|
+
|
|
118
|
+
If the response has trailers, the cache interceptor will pass them to the cache
|
|
119
|
+
interceptor through this method.
|
package/docs/docs/api/Client.md
CHANGED
|
@@ -86,37 +86,37 @@ const client = new Client('https://localhost:3000', {
|
|
|
86
86
|
|
|
87
87
|
### `Client.close([callback])`
|
|
88
88
|
|
|
89
|
-
Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
|
89
|
+
Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
|
|
90
90
|
|
|
91
91
|
### `Client.destroy([error, callback])`
|
|
92
92
|
|
|
93
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
93
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
94
94
|
|
|
95
95
|
Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided).
|
|
96
96
|
|
|
97
97
|
### `Client.connect(options[, callback])`
|
|
98
98
|
|
|
99
|
-
See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
|
99
|
+
See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
|
|
100
100
|
|
|
101
101
|
### `Client.dispatch(options, handlers)`
|
|
102
102
|
|
|
103
|
-
Implements [`Dispatcher.dispatch(options, handlers)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
103
|
+
Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
104
104
|
|
|
105
105
|
### `Client.pipeline(options, handler)`
|
|
106
106
|
|
|
107
|
-
See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
107
|
+
See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
108
108
|
|
|
109
109
|
### `Client.request(options[, callback])`
|
|
110
110
|
|
|
111
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
111
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
112
112
|
|
|
113
113
|
### `Client.stream(options, factory[, callback])`
|
|
114
114
|
|
|
115
|
-
See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
115
|
+
See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
116
116
|
|
|
117
117
|
### `Client.upgrade(options[, callback])`
|
|
118
118
|
|
|
119
|
-
See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
119
|
+
See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
120
120
|
|
|
121
121
|
## Instance Properties
|
|
122
122
|
|
|
@@ -142,7 +142,7 @@ Property to get and set the pipelining factor.
|
|
|
142
142
|
|
|
143
143
|
### Event: `'connect'`
|
|
144
144
|
|
|
145
|
-
See [Dispatcher Event: `'connect'`](Dispatcher.md#event-connect).
|
|
145
|
+
See [Dispatcher Event: `'connect'`](/docs/docs/api/Dispatcher.md#event-connect).
|
|
146
146
|
|
|
147
147
|
Parameters:
|
|
148
148
|
|
|
@@ -188,7 +188,7 @@ try {
|
|
|
188
188
|
|
|
189
189
|
### Event: `'disconnect'`
|
|
190
190
|
|
|
191
|
-
See [Dispatcher Event: `'disconnect'`](Dispatcher.md#event-disconnect).
|
|
191
|
+
See [Dispatcher Event: `'disconnect'`](/docs/docs/api/Dispatcher.md#event-disconnect).
|
|
192
192
|
|
|
193
193
|
Parameters:
|
|
194
194
|
|
|
@@ -233,7 +233,7 @@ try {
|
|
|
233
233
|
|
|
234
234
|
Emitted when pipeline is no longer busy.
|
|
235
235
|
|
|
236
|
-
See [Dispatcher Event: `'drain'`](Dispatcher.md#event-drain).
|
|
236
|
+
See [Dispatcher Event: `'drain'`](/docs/docs/api/Dispatcher.md#event-drain).
|
|
237
237
|
|
|
238
238
|
#### Example - Client drain event
|
|
239
239
|
|
|
@@ -377,7 +377,7 @@ Returns: `stream.Duplex`
|
|
|
377
377
|
|
|
378
378
|
#### Parameter: PipelineOptions
|
|
379
379
|
|
|
380
|
-
Extends: [`RequestOptions`](#parameter-requestoptions)
|
|
380
|
+
Extends: [`RequestOptions`](/docs/docs/api/Dispatcher.md#parameter-requestoptions)
|
|
381
381
|
|
|
382
382
|
* **objectMode** `boolean` (optional) - Default: `false` - Set to `true` if the `handler` will return an object stream.
|
|
383
383
|
|
|
@@ -467,7 +467,7 @@ Returns: `void | Promise<ResponseData>` - Only returns a `Promise` if no `callba
|
|
|
467
467
|
|
|
468
468
|
#### Parameter: `RequestOptions`
|
|
469
469
|
|
|
470
|
-
Extends: [`DispatchOptions`](#parameter-dispatchoptions)
|
|
470
|
+
Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)
|
|
471
471
|
|
|
472
472
|
* **opaque** `unknown` (optional) - Default: `null` - Used for passing through context to `ResponseData`.
|
|
473
473
|
* **signal** `AbortSignal | events.EventEmitter | null` (optional) - Default: `null`.
|
|
@@ -654,7 +654,7 @@ return null
|
|
|
654
654
|
|
|
655
655
|
A faster version of `Dispatcher.request`. This method expects the second argument `factory` to return a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable) stream which the response will be written to. This improves performance by avoiding creating an intermediate [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) stream when the user expects to directly pipe the response body to a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable) stream.
|
|
656
656
|
|
|
657
|
-
As demonstrated in [Example 1 - Basic GET stream request](#example-1---basic-get-stream-request), it is recommended to use the `option.opaque` property to avoid creating a closure for the `factory` method. This pattern works well with Node.js Web Frameworks such as [Fastify](https://fastify.io). See [Example 2 - Stream to Fastify Response](#example-2---stream-to-fastify-response) for more details.
|
|
657
|
+
As demonstrated in [Example 1 - Basic GET stream request](/docs/docs/api/Dispatcher.md#example-1---basic-get-stream-request), it is recommended to use the `option.opaque` property to avoid creating a closure for the `factory` method. This pattern works well with Node.js Web Frameworks such as [Fastify](https://fastify.io). See [Example 2 - Stream to Fastify Response](/docs/docs/api/Dispatch.md#example-2---stream-to-fastify-response) for more details.
|
|
658
658
|
|
|
659
659
|
Arguments:
|
|
660
660
|
|
|
@@ -936,7 +936,7 @@ await client.request({ path: '/', method: 'GET' })
|
|
|
936
936
|
|
|
937
937
|
The `redirect` interceptor allows you to customize the way your dispatcher handles redirects.
|
|
938
938
|
|
|
939
|
-
It accepts the same arguments as the [`RedirectHandler` constructor](
|
|
939
|
+
It accepts the same arguments as the [`RedirectHandler` constructor](/docs/docs/api/RedirectHandler.md).
|
|
940
940
|
|
|
941
941
|
**Example - Basic Redirect Interceptor**
|
|
942
942
|
|
|
@@ -954,7 +954,7 @@ client.request({ path: "/" })
|
|
|
954
954
|
|
|
955
955
|
The `retry` interceptor allows you to customize the way your dispatcher handles retries.
|
|
956
956
|
|
|
957
|
-
It accepts the same arguments as the [`RetryHandler` constructor](
|
|
957
|
+
It accepts the same arguments as the [`RetryHandler` constructor](/docs/docs/api/RetryHandler.md).
|
|
958
958
|
|
|
959
959
|
**Example - Basic Redirect Interceptor**
|
|
960
960
|
|
|
@@ -1260,7 +1260,7 @@ The `cache` interceptor implements client-side response caching as described in
|
|
|
1260
1260
|
|
|
1261
1261
|
**Options**
|
|
1262
1262
|
|
|
1263
|
-
- `store` - The [`CacheStore`](
|
|
1263
|
+
- `store` - The [`CacheStore`](/docs/docs/api/CacheStore.md) to store and retrieve responses from. Default is [`MemoryCacheStore`](/docs/docs/api/CacheStore.md#memorycachestore).
|
|
1264
1264
|
- `methods` - The [**safe** HTTP methods](https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1) to cache the response of.
|
|
1265
1265
|
|
|
1266
1266
|
## Instance Events
|
|
@@ -1309,13 +1309,13 @@ Emitted when dispatcher is no longer busy.
|
|
|
1309
1309
|
|
|
1310
1310
|
* `Record<string, string | string[] | undefined> | string[] | Iterable<[string, string | string[] | undefined]> | null`
|
|
1311
1311
|
|
|
1312
|
-
Header arguments such as `options.headers` in [`Client.dispatch`](Client.md#clientdispatchoptions-handlers) can be specified in three forms:
|
|
1312
|
+
Header arguments such as `options.headers` in [`Client.dispatch`](/docs/docs/api/Client.md#clientdispatchoptions-handlers) can be specified in three forms:
|
|
1313
1313
|
* As an object specified by the `Record<string, string | string[] | undefined>` (`IncomingHttpHeaders`) type.
|
|
1314
1314
|
* As an array of strings. An array representation of a header list must have an even length, or an `InvalidArgumentError` will be thrown.
|
|
1315
1315
|
* As an iterable that can encompass `Headers`, `Map`, or a custom iterator returning key-value pairs.
|
|
1316
1316
|
Keys are lowercase and values are not modified.
|
|
1317
1317
|
|
|
1318
|
-
Response headers will derive a `host` from the `url` of the [Client](Client.md#class-client) instance if no `host` header was previously specified.
|
|
1318
|
+
Response headers will derive a `host` from the `url` of the [Client](/docs/docs/api/Client.md#class-client) instance if no `host` header was previously specified.
|
|
1319
1319
|
|
|
1320
1320
|
### Example 1 - Object
|
|
1321
1321
|
|
|
@@ -20,7 +20,7 @@ Returns: `EnvHttpProxyAgent`
|
|
|
20
20
|
|
|
21
21
|
### Parameter: `EnvHttpProxyAgentOptions`
|
|
22
22
|
|
|
23
|
-
Extends: [`AgentOptions`](Agent.md#parameter-agentoptions)
|
|
23
|
+
Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
|
|
24
24
|
|
|
25
25
|
* **httpProxy** `string` (optional) - When set, it will override the `HTTP_PROXY` environment variable.
|
|
26
26
|
* **httpsProxy** `string` (optional) - When set, it will override the `HTTPS_PROXY` environment variable.
|
|
@@ -118,44 +118,44 @@ const data = await json() // data { foo: "bar" }
|
|
|
118
118
|
|
|
119
119
|
### `EnvHttpProxyAgent.close([callback])`
|
|
120
120
|
|
|
121
|
-
Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
|
121
|
+
Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
|
|
122
122
|
|
|
123
123
|
### `EnvHttpProxyAgent.destroy([error, callback])`
|
|
124
124
|
|
|
125
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
125
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
126
126
|
|
|
127
127
|
### `EnvHttpProxyAgent.dispatch(options, handler: AgentDispatchOptions)`
|
|
128
128
|
|
|
129
|
-
Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
129
|
+
Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
130
130
|
|
|
131
131
|
#### Parameter: `AgentDispatchOptions`
|
|
132
132
|
|
|
133
|
-
Extends: [`DispatchOptions`](Dispatcher.md#parameter-dispatchoptions)
|
|
133
|
+
Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)
|
|
134
134
|
|
|
135
135
|
* **origin** `string | URL`
|
|
136
136
|
|
|
137
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
137
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
138
138
|
|
|
139
139
|
### `EnvHttpProxyAgent.connect(options[, callback])`
|
|
140
140
|
|
|
141
|
-
See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
|
141
|
+
See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
|
|
142
142
|
|
|
143
143
|
### `EnvHttpProxyAgent.dispatch(options, handler)`
|
|
144
144
|
|
|
145
|
-
Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
145
|
+
Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
146
146
|
|
|
147
147
|
### `EnvHttpProxyAgent.pipeline(options, handler)`
|
|
148
148
|
|
|
149
|
-
See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
149
|
+
See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
150
150
|
|
|
151
151
|
### `EnvHttpProxyAgent.request(options[, callback])`
|
|
152
152
|
|
|
153
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
153
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
154
154
|
|
|
155
155
|
### `EnvHttpProxyAgent.stream(options, factory[, callback])`
|
|
156
156
|
|
|
157
|
-
See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
157
|
+
See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
158
158
|
|
|
159
159
|
### `EnvHttpProxyAgent.upgrade(options[, callback])`
|
|
160
160
|
|
|
161
|
-
See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
161
|
+
See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
@@ -14,7 +14,7 @@ Returns: `MockAgent`
|
|
|
14
14
|
|
|
15
15
|
### Parameter: `MockAgentOptions`
|
|
16
16
|
|
|
17
|
-
Extends: [`AgentOptions`](Agent.md#parameter-agentoptions)
|
|
17
|
+
Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
|
|
18
18
|
|
|
19
19
|
* **agent** `Agent` (optional) - Default: `new Agent([options])` - a custom agent encapsulated by the MockAgent.
|
|
20
20
|
|
|
@@ -301,11 +301,11 @@ await mockAgent.close()
|
|
|
301
301
|
|
|
302
302
|
### `MockAgent.dispatch(options, handlers)`
|
|
303
303
|
|
|
304
|
-
Implements [`Agent.dispatch(options, handlers)`](Agent.md#parameter-agentdispatchoptions).
|
|
304
|
+
Implements [`Agent.dispatch(options, handlers)`](/docs/docs/api/Agent.md#parameter-agentdispatchoptions).
|
|
305
305
|
|
|
306
306
|
### `MockAgent.request(options[, callback])`
|
|
307
307
|
|
|
308
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
308
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
309
309
|
|
|
310
310
|
#### Example - MockAgent request
|
|
311
311
|
|
|
@@ -36,19 +36,19 @@ const mockClient = mockAgent.get('http://localhost:3000')
|
|
|
36
36
|
|
|
37
37
|
### `MockClient.intercept(options)`
|
|
38
38
|
|
|
39
|
-
Implements: [`MockPool.intercept(options)`](MockPool.md#mockpoolinterceptoptions)
|
|
39
|
+
Implements: [`MockPool.intercept(options)`](/docs/docs/api/MockPool.md#mockpoolinterceptoptions)
|
|
40
40
|
|
|
41
41
|
### `MockClient.close()`
|
|
42
42
|
|
|
43
|
-
Implements: [`MockPool.close()`](MockPool.md#mockpoolclose)
|
|
43
|
+
Implements: [`MockPool.close()`](/docs/docs/api/MockPool.md#mockpoolclose)
|
|
44
44
|
|
|
45
45
|
### `MockClient.dispatch(options, handlers)`
|
|
46
46
|
|
|
47
|
-
Implements [`Dispatcher.dispatch(options, handlers)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
47
|
+
Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
48
48
|
|
|
49
49
|
### `MockClient.request(options[, callback])`
|
|
50
50
|
|
|
51
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
51
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
52
52
|
|
|
53
53
|
#### Example - MockClient request
|
|
54
54
|
|
|
@@ -512,11 +512,11 @@ await mockPool.close()
|
|
|
512
512
|
|
|
513
513
|
### `MockPool.dispatch(options, handlers)`
|
|
514
514
|
|
|
515
|
-
Implements [`Dispatcher.dispatch(options, handlers)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
515
|
+
Implements [`Dispatcher.dispatch(options, handlers)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
516
516
|
|
|
517
517
|
### `MockPool.request(options[, callback])`
|
|
518
518
|
|
|
519
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
519
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
520
520
|
|
|
521
521
|
#### Example - MockPool request
|
|
522
522
|
|
package/docs/docs/api/Pool.md
CHANGED
|
@@ -15,7 +15,7 @@ Arguments:
|
|
|
15
15
|
|
|
16
16
|
### Parameter: `PoolOptions`
|
|
17
17
|
|
|
18
|
-
Extends: [`ClientOptions`](Client.md#parameter-clientoptions)
|
|
18
|
+
Extends: [`ClientOptions`](/docs/docs/api/Client.md#parameter-clientoptions)
|
|
19
19
|
|
|
20
20
|
* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Client(origin, opts)`
|
|
21
21
|
* **connections** `number | null` (optional) - Default: `null` - The number of `Client` instances to create. When set to `null`, the `Pool` instance will create an unlimited amount of `Client` instances.
|
|
@@ -24,11 +24,11 @@ Extends: [`ClientOptions`](Client.md#parameter-clientoptions)
|
|
|
24
24
|
|
|
25
25
|
### `Pool.closed`
|
|
26
26
|
|
|
27
|
-
Implements [Client.closed](Client.md#clientclosed)
|
|
27
|
+
Implements [Client.closed](/docs/docs/api/Client.md#clientclosed)
|
|
28
28
|
|
|
29
29
|
### `Pool.destroyed`
|
|
30
30
|
|
|
31
|
-
Implements [Client.destroyed](Client.md#clientdestroyed)
|
|
31
|
+
Implements [Client.destroyed](/docs/docs/api/Client.md#clientdestroyed)
|
|
32
32
|
|
|
33
33
|
### `Pool.stats`
|
|
34
34
|
|
|
@@ -38,46 +38,46 @@ Returns [`PoolStats`](PoolStats.md) instance for this pool.
|
|
|
38
38
|
|
|
39
39
|
### `Pool.close([callback])`
|
|
40
40
|
|
|
41
|
-
Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
|
41
|
+
Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
|
|
42
42
|
|
|
43
43
|
### `Pool.destroy([error, callback])`
|
|
44
44
|
|
|
45
|
-
Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
45
|
+
Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
|
46
46
|
|
|
47
47
|
### `Pool.connect(options[, callback])`
|
|
48
48
|
|
|
49
|
-
See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
|
49
|
+
See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
|
|
50
50
|
|
|
51
51
|
### `Pool.dispatch(options, handler)`
|
|
52
52
|
|
|
53
|
-
Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
53
|
+
Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
|
|
54
54
|
|
|
55
55
|
### `Pool.pipeline(options, handler)`
|
|
56
56
|
|
|
57
|
-
See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
57
|
+
See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
|
|
58
58
|
|
|
59
59
|
### `Pool.request(options[, callback])`
|
|
60
60
|
|
|
61
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
61
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
62
62
|
|
|
63
63
|
### `Pool.stream(options, factory[, callback])`
|
|
64
64
|
|
|
65
|
-
See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
65
|
+
See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
|
66
66
|
|
|
67
67
|
### `Pool.upgrade(options[, callback])`
|
|
68
68
|
|
|
69
|
-
See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
69
|
+
See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
|
|
70
70
|
|
|
71
71
|
## Instance Events
|
|
72
72
|
|
|
73
73
|
### Event: `'connect'`
|
|
74
74
|
|
|
75
|
-
See [Dispatcher Event: `'connect'`](Dispatcher.md#event-connect).
|
|
75
|
+
See [Dispatcher Event: `'connect'`](/docs/docs/api/Dispatcher.md#event-connect).
|
|
76
76
|
|
|
77
77
|
### Event: `'disconnect'`
|
|
78
78
|
|
|
79
|
-
See [Dispatcher Event: `'disconnect'`](Dispatcher.md#event-disconnect).
|
|
79
|
+
See [Dispatcher Event: `'disconnect'`](/docs/docs/api/Dispatcher.md#event-disconnect).
|
|
80
80
|
|
|
81
81
|
### Event: `'drain'`
|
|
82
82
|
|
|
83
|
-
See [Dispatcher Event: `'drain'`](Dispatcher.md#event-drain).
|
|
83
|
+
See [Dispatcher Event: `'drain'`](/docs/docs/api/Dispatcher.md#event-drain).
|
|
@@ -14,7 +14,7 @@ Returns: `ProxyAgent`
|
|
|
14
14
|
|
|
15
15
|
### Parameter: `ProxyAgentOptions`
|
|
16
16
|
|
|
17
|
-
Extends: [`AgentOptions`](Agent.md#parameter-agentoptions)
|
|
17
|
+
Extends: [`AgentOptions`](/docs/docs/api/Agent.md#parameter-agentoptions)
|
|
18
18
|
|
|
19
19
|
* **uri** `string | URL` (required) - The URI of the proxy server. This can be provided as a string, as an instance of the URL class, or as an object with a `uri` property of type string.
|
|
20
20
|
If the `uri` is provided as a string or `uri` is an object with an `uri` property of type string, then it will be parsed into a `URL` object according to the [WHATWG URL Specification](https://url.spec.whatwg.org).
|
|
@@ -123,8 +123,8 @@ await proxyAgent.close()
|
|
|
123
123
|
|
|
124
124
|
### `ProxyAgent.dispatch(options, handlers)`
|
|
125
125
|
|
|
126
|
-
Implements [`Agent.dispatch(options, handlers)`](Agent.md#parameter-agentdispatchoptions).
|
|
126
|
+
Implements [`Agent.dispatch(options, handlers)`](/docs/docs/api/Agent.md#parameter-agentdispatchoptions).
|
|
127
127
|
|
|
128
128
|
### `ProxyAgent.request(options[, callback])`
|
|
129
129
|
|
|
130
|
-
See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
|
130
|
+
See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
|
|
@@ -15,7 +15,7 @@ Returns: `retryHandler`
|
|
|
15
15
|
|
|
16
16
|
### Parameter: `Dispatch.DispatchOptions & RetryOptions`
|
|
17
17
|
|
|
18
|
-
Extends: [`Dispatch.DispatchOptions`](Dispatcher.md#parameter-dispatchoptions).
|
|
18
|
+
Extends: [`Dispatch.DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions).
|
|
19
19
|
|
|
20
20
|
#### `RetryOptions`
|
|
21
21
|
|
|
@@ -44,7 +44,7 @@ It represents the retry state for a given request.
|
|
|
44
44
|
### Parameter `RetryHandlers`
|
|
45
45
|
|
|
46
46
|
- **dispatch** `(options: Dispatch.DispatchOptions, handlers: Dispatch.DispatchHandlers) => Promise<Dispatch.DispatchResponse>` (required) - Dispatch function to be called after every retry.
|
|
47
|
-
- **handler** Extends [`Dispatch.DispatchHandlers`](Dispatcher.md#dispatcherdispatchoptions-handler) (required) - Handler function to be called after the request is successful or the retries are exhausted.
|
|
47
|
+
- **handler** Extends [`Dispatch.DispatchHandlers`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler) (required) - Handler function to be called after the request is successful or the retries are exhausted.
|
|
48
48
|
|
|
49
49
|
>__Note__: The `RetryHandler` does not retry over stateful bodies (e.g. streams, AsyncIterable) as those, once consumed, are left in a state that cannot be reutilized. For these situations the `RetryHandler` will identify
|
|
50
50
|
>the body as stateful and will not retry the request rejecting with the error `UND_ERR_REQ_RETRY`.
|
|
@@ -9,7 +9,7 @@ The WebSocket object provides a way to manage a WebSocket connection to a server
|
|
|
9
9
|
Arguments:
|
|
10
10
|
|
|
11
11
|
* **url** `URL | string`
|
|
12
|
-
* **protocol** `string | string[] | WebSocketInit` (optional) - Subprotocol(s) to request the server use, or a [`Dispatcher`](
|
|
12
|
+
* **protocol** `string | string[] | WebSocketInit` (optional) - Subprotocol(s) to request the server use, or a [`Dispatcher`](/docs/docs/api/Dispatcher.md).
|
|
13
13
|
|
|
14
14
|
### Example:
|
|
15
15
|
|