Skip to content

Commit 2901abe

Browse files
nodejs-github-bottargos
authored andcommittedNov 7, 2022
deps: update undici to 5.11.0
PR-URL: #44929 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent c80cf97 commit 2901abe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+10995
-1374
lines changed
 

‎deps/undici/src/README.md

+33-11
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ Help us improve the test coverage by following instructions at [nodejs/undici/#9
185185
Basic usage example:
186186

187187
```js
188-
import { fetch } from 'undici';
188+
import { fetch } from 'undici'
189189

190190

191191
const res = await fetch('https://example.com')
192192
const json = await res.json()
193-
console.log(json);
193+
console.log(json)
194194
```
195195

196196
You can pass an optional dispatcher to `fetch` as:
@@ -225,29 +225,29 @@ A body can be of the following types:
225225
In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
226226

227227
```js
228-
import { fetch } from "undici";
228+
import { fetch } from 'undici'
229229

230230
const data = {
231231
async *[Symbol.asyncIterator]() {
232-
yield "hello";
233-
yield "world";
232+
yield 'hello'
233+
yield 'world'
234234
},
235-
};
235+
}
236236

237-
await fetch("https://example.com", { body: data, method: 'POST' });
237+
await fetch('https://example.com', { body: data, method: 'POST' })
238238
```
239239

240240
#### `response.body`
241241

242242
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()`.
243243

244244
```js
245-
import { fetch } from 'undici';
246-
import { Readable } from 'node:stream';
245+
import { fetch } from 'undici'
246+
import { Readable } from 'node:stream'
247247

248248
const response = await fetch('https://example.com')
249-
const readableWebStream = response.body;
250-
const readableNodeStream = Readable.fromWeb(readableWebStream);
249+
const readableWebStream = response.body
250+
const readableNodeStream = Readable.fromWeb(readableWebStream)
251251
```
252252

253253
#### Specification Compliance
@@ -329,6 +329,28 @@ Gets the global dispatcher used by Common API Methods.
329329

330330
Returns: `Dispatcher`
331331

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.
339+
340+
```js
341+
setGlobalOrigin('http://localhost:3000')
342+
343+
const response = await fetch('/api/ping')
344+
345+
console.log(response.url) // http://localhost:3000/api/ping
346+
```
347+
348+
### `undici.getGlobalOrigin()`
349+
350+
Gets the global origin used in `fetch`.
351+
352+
Returns: `URL`
353+
332354
### `UrlObject`
333355

334356
* **port** `string | number` (optional)

‎deps/undici/src/docs/api/Agent.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Returns: `Agent`
1616

1717
### Parameter: `AgentOptions`
1818

19-
Extends: [`ClientOptions`](Pool.md#parameter-pooloptions)
19+
Extends: [`PoolOptions`](Pool.md#parameter-pooloptions)
2020

2121
* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
2222
* **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.
2324

2425
## Instance Properties
2526

0 commit comments

Comments
 (0)
Please sign in to comment.