You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: deps/undici/src/README.md
+33-11
Original file line number
Diff line number
Diff line change
@@ -185,12 +185,12 @@ Help us improve the test coverage by following instructions at [nodejs/undici/#9
185
185
Basic usage example:
186
186
187
187
```js
188
-
import { fetch } from'undici';
188
+
import { fetch } from'undici'
189
189
190
190
191
191
constres=awaitfetch('https://example.com')
192
192
constjson=awaitres.json()
193
-
console.log(json);
193
+
console.log(json)
194
194
```
195
195
196
196
You can pass an optional dispatcher to `fetch` as:
@@ -225,29 +225,29 @@ A body can be of the following types:
225
225
In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
@@ -329,6 +329,28 @@ Gets the global dispatcher used by Common API Methods.
329
329
330
330
Returns: `Dispatcher`
331
331
332
+
### `undici.setGlobalOrigin(origin)`
333
+
334
+
* origin `string | URL | undefined`
335
+
336
+
Sets the global origin used in `fetch`.
337
+
338
+
If `undefined` is passed, the global origin will be reset. This will cause `Response.redirect`, `new Request()`, and `fetch` to throw an error when a relative path is passed.
***maxRedirections**`Integer` - Default: `0`. The number of HTTP redirection to follow unless otherwise specified in `DispatchOptions`.
23
+
***interceptors**`{ Agent: DispatchInterceptor[] }` - Default: `[RedirectInterceptor]` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching). Note that the behavior of interceptors is Experimental and might change at any given time.
Copy file name to clipboardexpand all lines: deps/undici/src/docs/api/Client.md
+1
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ Returns: `Client`
26
26
***pipelining**`number | null` (optional) - Default: `1` - The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Carefully consider your workload and environment before enabling concurrent requests as pipelining may reduce performance if used incorrectly. Pipelining is sensitive to network stack settings as well as head of line blocking caused by e.g. long running requests. Set to `0` to disable keep-alive connections.
27
27
***connect**`ConnectOptions | Function | null` (optional) - Default: `null`.
28
28
***strictContentLength**`Boolean` (optional) - Default: `true` - Whether to treat request content length mismatches as errors. If true, an error is thrown when the request content-length header doesn't match the length of the request body.
29
+
***interceptors**`{ Client: DispatchInterceptor[] }` - Default: `[RedirectInterceptor]` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching). Note that the behavior of interceptors is Experimental and might change at any given time.
Copy file name to clipboardexpand all lines: deps/undici/src/docs/api/MockPool.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ Returns: `MockInterceptor` corresponding to the input options.
54
54
### Parameter: `MockPoolInterceptOptions`
55
55
56
56
***path**`string | RegExp | (path: string) => boolean` - a matcher for the HTTP request path.
57
-
***method**`string | RegExp | (method: string) => boolean` - a matcher for the HTTP request method.
57
+
***method**`string | RegExp | (method: string) => boolean` - (optional) - a matcher for the HTTP request method. Defaults to `GET`.
58
58
***body**`string | RegExp | (body: string) => boolean` - (optional) - a matcher for the HTTP request body.
59
59
***headers**`Record<string, string | RegExp | (body: string) => boolean`> - (optional) - a matcher for the HTTP request headers. To be intercepted, a request must match all defined headers. Extra headers not defined here may (or may not) be included in the request and do not affect the interception in any way.
60
60
***query**`Record<string, any> | null` - (optional) - a matcher for the HTTP request query string params.
***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.
22
+
***interceptors**`{ Pool: DispatchInterceptor[] } }` - Default: `{ Pool: [] }` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching).
0 commit comments