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
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).
@@ -477,7 +477,7 @@ The `RequestOptions.method` property should not be value `'CONNECT'`.
477
477
#### Parameter: `ResponseData`
478
478
479
479
***statusCode**`number`
480
-
***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`.
481
481
***body**`stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
482
482
***trailers**`Record<string, string>` - This object starts out
483
483
as empty and will be mutated to contain trailers after `body` has emitted `'end'`.
@@ -631,7 +631,7 @@ try {
631
631
632
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.
633
633
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
+
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.
635
635
636
636
Arguments:
637
637
@@ -644,7 +644,7 @@ Returns: `void | Promise<StreamData>` - Only returns a `Promise` if no `callback
644
644
#### Parameter: `StreamFactoryData`
645
645
646
646
***statusCode**`number`
647
-
***headers**`http.IncomingHttpHeaders`
647
+
***headers**`Record<string, string | string[]>`
648
648
***opaque**`unknown`
649
649
***onInfo**`({statusCode: number, headers: Record<string, string | string[]>}) => void | null` (optional) - Default: `null` - Callback collecting all the info headers (HTTP 100-199) received.
650
650
@@ -853,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.
/** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
107
107
idempotent?: boolean;
108
+
/** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. */
109
+
blocking?: boolean;
108
110
/** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
109
111
upgrade?: boolean|string|null;
110
112
/** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 30 seconds. */
0 commit comments