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
This is [experimental](https://nodejs.org/api/documentation.html#documentation_stability_index) and is not yet fully compliant with the Fetch Standard.
182
-
We plan to ship breaking changes to this feature until it is out of experimental.
183
-
Help us improve the test coverage by following instructions at [nodejs/undici/#951](https://github.com/nodejs/undici/issues/951).
In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`. And fetch requests are currently always be full duplex. More detail refer to [Fetch Standard.](https://fetch.spec.whatwg.org/#dom-requestinit-duplex)
241
+
240
242
#### `response.body`
241
243
242
244
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()`.
Copy file name to clipboardExpand all lines: deps/undici/src/docs/api/Client.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,8 @@ Furthermore, the following options can be passed:
38
38
***maxCachedSessions**`number | null` (optional) - Default: `100` - Maximum number of TLS cached sessions. Use 0 to disable TLS session caching. Default: 100.
Implements [parse a MIME type](https://mimesniff.spec.whatwg.org/#parse-a-mime-type).
13
+
14
+
Parses a MIME type, returning its type, subtype, and any associated parameters. If the parser can't parse an input it returns the string literal `'failure'`.
15
+
16
+
```js
17
+
import { parseMIMEType } from'undici'
18
+
19
+
parseMIMEType('text/html; charset=gbk')
20
+
// {
21
+
// type: 'text',
22
+
// subtype: 'html',
23
+
// parameters: Map(1) { 'charset' => 'gbk' },
24
+
// essence: 'text/html'
25
+
// }
26
+
```
27
+
28
+
Arguments:
29
+
30
+
***input**`string`
31
+
32
+
Returns: `MIMEType|'failure'`
33
+
34
+
## `serializeAMimeType(input)`
35
+
36
+
Implements [serialize a MIME type](https://mimesniff.spec.whatwg.org/#serialize-a-mime-type).
Copy file name to clipboardExpand all lines: deps/undici/src/docs/api/Dispatcher.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ Returns: `void | Promise<ConnectData>` - Only returns a `Promise` if no `callbac
74
74
#### Parameter: `ConnectData`
75
75
76
76
***statusCode**`number`
77
-
***headers**`http.IncomingHttpHeaders`
77
+
***headers**`Record<string, string | string[]>`
78
78
***socket**`stream.Duplex`
79
79
***opaque**`unknown`
80
80
@@ -192,6 +192,7 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo
192
192
***origin**`string | URL`
193
193
***path**`string`
194
194
***method**`string`
195
+
***reset**`boolean` (optional) - Default: `false` - If `false`, the request will attempt to create a long-living connection by sending the `connection: keep-alive` header,otherwise will attempt to close it immediately after response by sending `connection: close` within the request and closing the socket afterwards.
***query**`Record<string, any> | null` (optional) - Default: `null` - Query string params to be embedded in the request URL. Note that both keys and values of query are encoded using `encodeURIComponent`. If for some reason you need to send them unencoded, embed query params into path directly instead.
@@ -476,7 +477,7 @@ The `RequestOptions.method` property should not be value `'CONNECT'`.
476
477
#### Parameter: `ResponseData`
477
478
478
479
***statusCode**`number`
479
-
***headers**`http.IncomingHttpHeaders` - Note that all header keys are lower-cased, e. g. `content-type`.
480
+
***headers**`Record<string, string | string[]>` - Note that all header keys are lower-cased, e. g. `content-type`.
480
481
***body**`stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
481
482
***trailers**`Record<string, string>` - This object starts out
482
483
as empty and will be mutated to contain trailers after `body` has emitted `'end'`.
@@ -630,7 +631,7 @@ try {
630
631
631
632
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.
632
633
633
-
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.
634
+
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.
634
635
635
636
Arguments:
636
637
@@ -643,7 +644,7 @@ Returns: `void | Promise<StreamData>` - Only returns a `Promise` if no `callback
643
644
#### Parameter: `StreamFactoryData`
644
645
645
646
***statusCode**`number`
646
-
***headers**`http.IncomingHttpHeaders`
647
+
***headers**`Record<string, string | string[]>`
647
648
***opaque**`unknown`
648
649
***onInfo**`({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
649
650
@@ -852,9 +853,9 @@ Emitted when dispatcher is no longer busy.
Header arguments such as `options.headers` in [`Client.dispatch`](Client.md#clientdispatchoptions-handlers) can be specified in two forms; either as an object specified by the `http.IncomingHttpHeaders` type, or an array of strings. An array representation of a header list must have an even length or an `InvalidArgumentError` will be thrown.
858
+
Header arguments such as `options.headers` in [`Client.dispatch`](Client.md#clientdispatchoptions-handlers) can be specified in two forms; either as an object specified by the `Record<string, string | string[]>` (`IncomingHttpHeaders`) type, or an array of strings. An array representation of a header list must have an even length or an `InvalidArgumentError` will be thrown.
Copy file name to clipboardExpand all lines: deps/undici/src/docs/api/MockPool.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,8 @@ Returns: `MockInterceptor` corresponding to the input options.
63
63
64
64
We can define the behaviour of an intercepted request with the following options.
65
65
66
-
***reply**`(statusCode: number, replyData: string | Buffer | object | MockInterceptor.MockResponseDataHandler, responseOptions?: MockResponseOptions) => MockScope` - define a reply for a matching request. You can define this as a callback to read incoming request data. Default for `responseOptions` is `{}`.
66
+
***reply**`(statusCode: number, replyData: string | Buffer | object | MockInterceptor.MockResponseDataHandler, responseOptions?: MockResponseOptions) => MockScope` - define a reply for a matching request. You can define the replyData as a callback to read incoming request data. Default for `responseOptions` is `{}`.
67
+
***reply**`(callback: MockInterceptor.MockReplyOptionsCallback) => MockScope` - define a reply for a matching request, allowing dynamic mocking of all reply options rather than just the data.
67
68
***replyWithError**`(error: Error) => MockScope` - define an error for a matching request to throw.
68
69
***defaultReplyHeaders**`(headers: Record<string, string>) => MockInterceptor` - define default headers to be included in subsequent replies. These are in addition to headers on a specific reply.
69
70
***defaultReplyTrailers**`(trailers: Record<string, string>) => MockInterceptor` - define default trailers to be included in subsequent replies. These are in addition to trailers on a specific reply.
0 commit comments