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
+25-9Lines changed: 25 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -281,17 +281,23 @@ stalls or deadlocks when running out of connections.
281
281
282
282
```js
283
283
// Do
284
-
constheaders=awaitfetch(url)
285
-
.then(asyncres=> {
286
-
forawait (constchunkofres.body) {
287
-
// force consumption of body
288
-
}
289
-
returnres.headers
290
-
})
284
+
const { body, headers } =awaitfetch(url);
285
+
forawait (constchunkofbody) {
286
+
// force consumption of body
287
+
}
291
288
292
289
// Do not
293
-
constheaders=awaitfetch(url)
294
-
.then(res=>res.headers)
290
+
const { headers } =awaitfetch(url);
291
+
```
292
+
293
+
The same applies for `request` too:
294
+
```js
295
+
// Do
296
+
const { body, headers } =awaitrequest(url);
297
+
awaitres.body.dump(); // force consumption of body
298
+
299
+
// Do not
300
+
const { headers } =awaitrequest(url);
295
301
```
296
302
297
303
However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
@@ -445,6 +451,16 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es
***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
21
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).
21
22
For detailed information on the parsing process and potential validation errors, please refer to the ["Writing" section](https://url.spec.whatwg.org/#writing) of the WHATWG URL Specification.
22
23
***token**`string` (optional) - It can be passed by a string of token for authentication.
***requestTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
26
-
***proxyTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback).
26
+
***requestTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
27
+
***proxyTls**`BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. It extends from [`Client#ConnectOptions`](/docs/docs/api/Client.md#parameter-connectoptions).
27
28
28
29
Examples:
29
30
@@ -35,6 +36,13 @@ const proxyAgent = new ProxyAgent('my.proxy.server')
0 commit comments