{
  "type": "module",
  "source": "doc/api/api-client.md",
  "modules": [
    {
      "textRaw": "Client",
      "name": "client",
      "introduced_in": "v1.0.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>A basic HTTP/1.1 client mapped on top of a single TCP/TLS connection. When the\nserver supports HTTP/2 and selects it during ALPN negotiation, the same\nconnection is used for HTTP/2. Pipelining is disabled by default.</p>\n<p><code>Client</code> extends <a href=\"Dispatcher.html#class-dispatcher\"><code>Dispatcher</code></a> and is the lowest-level dispatcher in undici:\nit manages exactly one origin over one connection. For pooling across multiple\nconnections use <a href=\"Pool.html#class-pool\"><code>Pool</code></a>, and for routing across multiple origins use\n<a href=\"Agent.html#class-agent\"><code>Agent</code></a>. Requests are not guaranteed to be dispatched in the order in which\nthey are invoked.</p>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\n\nconst client = new Client('http://localhost:3000')\nconst { statusCode, body } = await client.request({ path: '/', method: 'GET' })\n</code></pre>",
      "classes": [
        {
          "textRaw": "Class: `Client`",
          "name": "Client",
          "type": "class",
          "meta": {
            "added": [
              "v1.0.0"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"Dispatcher.md#class-dispatcher\"><code>&#x3C;Dispatcher></code></a></li>\n</ul>",
          "signatures": [
            {
              "textRaw": "`new Client(url[, options])`",
              "name": "Client",
              "type": "ctor",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`url` {URL|string} The origin to connect to. Only the protocol, hostname, and port are used.",
                  "name": "url",
                  "type": "URL|string",
                  "desc": "The origin to connect to. Only the protocol, hostname, and port are used."
                },
                {
                  "textRaw": "`options` {Object} (optional)",
                  "name": "options",
                  "type": "Object",
                  "desc": "(optional)",
                  "options": [
                    {
                      "textRaw": "`bodyTimeout` {number|null} The timeout, in milliseconds, after which a request times out while receiving body data. Monitors the time between consecutive body chunks. Use `0` to disable it entirely. **Default:** `300e3`.",
                      "name": "bodyTimeout",
                      "type": "number|null",
                      "default": "`300e3`",
                      "desc": "The timeout, in milliseconds, after which a request times out while receiving body data. Monitors the time between consecutive body chunks. Use `0` to disable it entirely."
                    },
                    {
                      "textRaw": "`headersTimeout` {number|null} The timeout, in milliseconds, the parser waits to receive the complete HTTP headers before the request times out. Use `0` to disable it entirely. **Default:** `300e3`.",
                      "name": "headersTimeout",
                      "type": "number|null",
                      "default": "`300e3`",
                      "desc": "The timeout, in milliseconds, the parser waits to receive the complete HTTP headers before the request times out. Use `0` to disable it entirely."
                    },
                    {
                      "textRaw": "`connectTimeout` {number|null} The timeout, in milliseconds, for establishing a socket connection. Use `0` to disable it entirely. **Default:** `10e3`.",
                      "name": "connectTimeout",
                      "type": "number|null",
                      "default": "`10e3`",
                      "desc": "The timeout, in milliseconds, for establishing a socket connection. Use `0` to disable it entirely."
                    },
                    {
                      "textRaw": "`keepAliveTimeout` {number|null} The timeout, in milliseconds, after which a socket with no active requests times out. Monitors the time between activity on a connected socket. This value may be overridden by _keep-alive_ hints from the server. **Default:** `4e3`.",
                      "name": "keepAliveTimeout",
                      "type": "number|null",
                      "default": "`4e3`",
                      "desc": "The timeout, in milliseconds, after which a socket with no active requests times out. Monitors the time between activity on a connected socket. This value may be overridden by _keep-alive_ hints from the server."
                    },
                    {
                      "textRaw": "`keepAliveMaxTimeout` {number|null} The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by _keep-alive_ hints from the server. **Default:** `600e3`.",
                      "name": "keepAliveMaxTimeout",
                      "type": "number|null",
                      "default": "`600e3`",
                      "desc": "The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by _keep-alive_ hints from the server."
                    },
                    {
                      "textRaw": "`keepAliveTimeoutThreshold` {number|null} A number of milliseconds subtracted from server _keep-alive_ hints when overriding `keepAliveTimeout`, to account for timing inaccuracies caused by e.g. transport latency. **Default:** `2e3`.",
                      "name": "keepAliveTimeoutThreshold",
                      "type": "number|null",
                      "default": "`2e3`",
                      "desc": "A number of milliseconds subtracted from server _keep-alive_ hints when overriding `keepAliveTimeout`, to account for timing inaccuracies caused by e.g. transport latency."
                    },
                    {
                      "textRaw": "`maxHeaderSize` {number|null} The maximum length of request headers, in bytes. **Default:** the value of Node.js' `--max-http-header-size` or `16384` (16 KiB).",
                      "name": "maxHeaderSize",
                      "type": "number|null",
                      "default": "the value of Node.js' `--max-http-header-size` or `16384` (16 KiB)",
                      "desc": "The maximum length of request headers, in bytes."
                    },
                    {
                      "textRaw": "`maxResponseSize` {number|null} The maximum length of a response body, in bytes. Set to `-1` to disable it. **Default:** `-1`.",
                      "name": "maxResponseSize",
                      "type": "number|null",
                      "default": "`-1`",
                      "desc": "The maximum length of a response body, in bytes. Set to `-1` to disable it."
                    },
                    {
                      "textRaw": "`maxRequestsPerClient` {number|null} The maximum number of requests to send over a single connection before the socket is reset. Use `0` to disable this limit. **Default:** `null`.",
                      "name": "maxRequestsPerClient",
                      "type": "number|null",
                      "default": "`null`",
                      "desc": "The maximum number of requests to send over a single connection before the socket is reset. Use `0` to disable this limit."
                    },
                    {
                      "textRaw": "`localAddress` {string|null} The local IP address the socket should connect from. **Default:** `null`.",
                      "name": "localAddress",
                      "type": "string|null",
                      "default": "`null`",
                      "desc": "The local IP address the socket should connect from."
                    },
                    {
                      "textRaw": "`pipelining` {number|null} The number of concurrent requests sent over the single connection, per RFC 7230, section 6.3.2. Only enable values greater than `1` when the remote server is trusted. Set to `0` to disable keep-alive connections. Has no effect once HTTP/2 is negotiated; see `maxConcurrentStreams` for the HTTP/2 dispatch ceiling. **Default:** `1`.",
                      "name": "pipelining",
                      "type": "number|null",
                      "default": "`1`",
                      "desc": "The number of concurrent requests sent over the single connection, per RFC 7230, section 6.3.2. Only enable values greater than `1` when the remote server is trusted. Set to `0` to disable keep-alive connections. Has no effect once HTTP/2 is negotiated; see `maxConcurrentStreams` for the HTTP/2 dispatch ceiling."
                    },
                    {
                      "textRaw": "`connect` {Object|Function|null} Configures how connections are established. Either a `ConnectOptions` object passed to the built-in `buildConnector` (every [`tls.connect()`][] option is accepted, plus the fields below), or a custom connector function with the signature `(options, callback)`. **Default:** `null`.",
                      "name": "connect",
                      "type": "Object|Function|null",
                      "default": "`null`",
                      "desc": "Configures how connections are established. Either a `ConnectOptions` object passed to the built-in `buildConnector` (every [`tls.connect()`][] option is accepted, plus the fields below), or a custom connector function with the signature `(options, callback)`.",
                      "options": [
                        {
                          "textRaw": "`socketPath` {string|null} An IPC endpoint, either a Unix domain socket or a Windows named pipe. **Default:** `null`.",
                          "name": "socketPath",
                          "type": "string|null",
                          "default": "`null`",
                          "desc": "An IPC endpoint, either a Unix domain socket or a Windows named pipe."
                        },
                        {
                          "textRaw": "`maxCachedSessions` {number|null} The maximum number of cached TLS sessions. Use `0` to disable TLS session caching. **Default:** `100`.",
                          "name": "maxCachedSessions",
                          "type": "number|null",
                          "default": "`100`",
                          "desc": "The maximum number of cached TLS sessions. Use `0` to disable TLS session caching."
                        },
                        {
                          "textRaw": "`timeout` {number|null} The connection timeout, in milliseconds. **Default:** `10e3`.",
                          "name": "timeout",
                          "type": "number|null",
                          "default": "`10e3`",
                          "desc": "The connection timeout, in milliseconds."
                        },
                        {
                          "textRaw": "`servername` {string|null} The TLS server name used for SNI.",
                          "name": "servername",
                          "type": "string|null",
                          "desc": "The TLS server name used for SNI."
                        },
                        {
                          "textRaw": "`keepAlive` {boolean|null} Whether TCP keep-alive is enabled on the socket. **Default:** `true`.",
                          "name": "keepAlive",
                          "type": "boolean|null",
                          "default": "`true`",
                          "desc": "Whether TCP keep-alive is enabled on the socket."
                        },
                        {
                          "textRaw": "`keepAliveInitialDelay` {number|null} The TCP keep-alive interval for the socket, in milliseconds. **Default:** `60000`.",
                          "name": "keepAliveInitialDelay",
                          "type": "number|null",
                          "default": "`60000`",
                          "desc": "The TCP keep-alive interval for the socket, in milliseconds."
                        }
                      ]
                    },
                    {
                      "textRaw": "`strictContentLength` {boolean} Whether to throw when the request `content-length` header does not match the length of the request body. Disabling this exposes the application to HTTP request smuggling; only do so in controlled environments where the request source is fully trusted. **Default:** `true`.",
                      "name": "strictContentLength",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "Whether to throw when the request `content-length` header does not match the length of the request body. Disabling this exposes the application to HTTP request smuggling; only do so in controlled environments where the request source is fully trusted."
                    },
                    {
                      "textRaw": "`autoSelectFamily` {boolean} Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. Ignored if unsupported by the current Node.js version. **Default:** `false`.",
                      "name": "autoSelectFamily",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. Ignored if unsupported by the current Node.js version."
                    },
                    {
                      "textRaw": "`autoSelectFamilyAttemptTimeout` {number} The time, in milliseconds, to wait for a connection attempt to finish before trying the next address when `autoSelectFamily` is enabled. **Default:** `250`.",
                      "name": "autoSelectFamilyAttemptTimeout",
                      "type": "number",
                      "default": "`250`",
                      "desc": "The time, in milliseconds, to wait for a connection attempt to finish before trying the next address when `autoSelectFamily` is enabled."
                    },
                    {
                      "textRaw": "`allowH2` {boolean} Enables HTTP/2 support when the server assigns it a higher priority through ALPN negotiation. **Default:** `true`.",
                      "name": "allowH2",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "Enables HTTP/2 support when the server assigns it a higher priority through ALPN negotiation."
                    },
                    {
                      "textRaw": "`useH2c` {boolean} Enforces h2c (HTTP/2 cleartext) for non-HTTPS connections. **Default:** `false`.",
                      "name": "useH2c",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Enforces h2c (HTTP/2 cleartext) for non-HTTPS connections."
                    },
                    {
                      "textRaw": "`maxConcurrentStreams` {number} The maximum number of concurrent HTTP/2 streams for a single session. Once h2 is negotiated this — not `pipelining`, which is HTTP/1.1 only — is the ceiling used to dispatch in-flight requests. It may be overridden by the server's `SETTINGS_MAX_CONCURRENT_STREAMS` frame. **Default:** `100`.",
                      "name": "maxConcurrentStreams",
                      "type": "number",
                      "default": "`100`",
                      "desc": "The maximum number of concurrent HTTP/2 streams for a single session. Once h2 is negotiated this — not `pipelining`, which is HTTP/1.1 only — is the ceiling used to dispatch in-flight requests. It may be overridden by the server's `SETTINGS_MAX_CONCURRENT_STREAMS` frame."
                    },
                    {
                      "textRaw": "`initialWindowSize` {number} The HTTP/2 stream-level flow-control window size (`SETTINGS_INITIAL_WINDOW_SIZE`). Must be a positive integer. **Default:** `262144`.",
                      "name": "initialWindowSize",
                      "type": "number",
                      "default": "`262144`",
                      "desc": "The HTTP/2 stream-level flow-control window size (`SETTINGS_INITIAL_WINDOW_SIZE`). Must be a positive integer."
                    },
                    {
                      "textRaw": "`connectionWindowSize` {number} The HTTP/2 connection-level flow-control window size set via `ClientHttp2Session.setLocalWindowSize()`. Must be a positive integer. **Default:** `524288`.",
                      "name": "connectionWindowSize",
                      "type": "number",
                      "default": "`524288`",
                      "desc": "The HTTP/2 connection-level flow-control window size set via `ClientHttp2Session.setLocalWindowSize()`. Must be a positive integer."
                    },
                    {
                      "textRaw": "`pingInterval` {number} The time interval, in milliseconds, between HTTP/2 PING frames. Set to `0` to disable PING frames. Applies only to HTTP/2 connections and emits a `ping` event on the client. **Default:** `60e3`.",
                      "name": "pingInterval",
                      "type": "number",
                      "default": "`60e3`",
                      "desc": "The time interval, in milliseconds, between HTTP/2 PING frames. Set to `0` to disable PING frames. Applies only to HTTP/2 connections and emits a `ping` event on the client."
                    },
                    {
                      "textRaw": "`webSocket` {Object} (optional) WebSocket-specific configuration.",
                      "name": "webSocket",
                      "type": "Object",
                      "desc": "(optional) WebSocket-specific configuration.",
                      "options": [
                        {
                          "textRaw": "`maxFragments` {number} The maximum number of fragments in a message. Set to `0` to disable the limit. **Default:** `131072`.",
                          "name": "maxFragments",
                          "type": "number",
                          "default": "`131072`",
                          "desc": "The maximum number of fragments in a message. Set to `0` to disable the limit."
                        },
                        {
                          "textRaw": "`maxPayloadSize` {number} The maximum allowed payload size, in bytes, for WebSocket messages. Applied to uncompressed messages, compressed frame payloads, and decompressed (`permessage-deflate`) messages. Set to `0` to disable the limit. **Default:** `134217728`.",
                          "name": "maxPayloadSize",
                          "type": "number",
                          "default": "`134217728`",
                          "desc": "The maximum allowed payload size, in bytes, for WebSocket messages. Applied to uncompressed messages, compressed frame payloads, and decompressed (`permessage-deflate`) messages. Set to `0` to disable the limit."
                        }
                      ]
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {Client}",
                "name": "return",
                "type": "Client"
              },
              "desc": "<p>Instantiating a <code>Client</code> does not open a connection; the connection is\nestablished lazily once a request is queued. Call <code>client.connect()</code> to connect\neagerly.</p>\n<blockquote>\n<p>Notes about HTTP/2:</p>\n<ul>\n<li>Pseudo headers (<code>:path</code>, <code>:method</code>, <code>:scheme</code>, <code>:authority</code>) are attached\nautomatically and overwrite any user-provided values.</li>\n<li>The server must support HTTP/2 and select it during ALPN negotiation, and\nmust not give HTTP/1.1 a higher priority than HTTP/2.</li>\n<li><code>PUSH</code> frames are not supported.</li>\n</ul>\n</blockquote>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\n\nconst client = new Client('http://localhost:3000')\n</code></pre>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\nimport { readFileSync } from 'node:fs'\n\nconst client = new Client('https://localhost:3000', {\n  connect: {\n    rejectUnauthorized: false,\n    ca: readFileSync('./ca-cert.pem')\n  }\n})\n</code></pre>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\n\nconst client = new Client('http://localhost:3000', {\n  connect: {\n    socketPath: '/var/run/docker.sock'\n  }\n})\n</code></pre>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\nimport dns from 'node:dns'\n\nconst client = new Client('https://example.com', {\n  connect: {\n    lookup (hostname, options, callback) {\n      dns.lookup(hostname, { ...options, family: 4 }, callback)\n    }\n  }\n})\n</code></pre>\n<pre><code class=\"language-mjs\">import { Client, buildConnector } from 'undici'\n\nconst connector = buildConnector({ rejectUnauthorized: false })\nconst client = new Client('https://localhost:3000', {\n  connect (opts, cb) {\n    connector(opts, (err, socket) => {\n      if (err) {\n        cb(err)\n      } else {\n        cb(null, socket)\n      }\n    })\n  }\n})\n</code></pre>\n<p>When a connector function is provided, undici wraps it to automatically inject\n<code>socketPath</code> and <code>allowH2</code> into the <code>options</code> argument when those values are set\non the client. See <a href=\"Connector.html\"><code>Connector</code></a> for details on building custom connectors.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`client.close([callback])`",
              "name": "close",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "callback",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Implements [<code>dispatcher.close([callback])</code>][]. Closes the client gracefully,\nwaiting for enqueued requests to complete before resolving.</p>"
            },
            {
              "textRaw": "`client.destroy([error[, callback]])`",
              "name": "destroy",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "error",
                      "optional": true
                    },
                    {
                      "name": "callback",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Implements [<code>dispatcher.destroy([error[, callback]])</code>][]. Destroys the client\nabruptly, aborting all pending and running requests, and waits until the socket\nis closed before invoking <code>callback</code> (or resolving the returned promise).</p>"
            },
            {
              "textRaw": "`client.connect(options[, callback])`",
              "name": "connect",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object} The connect options, identical to [`dispatcher.connect()`][] except that `origin` is omitted because the client is bound to a single origin.",
                      "name": "options",
                      "type": "Object",
                      "desc": "The connect options, identical to [`dispatcher.connect()`][] except that `origin` is omitted because the client is bound to a single origin."
                    },
                    {
                      "textRaw": "`callback` {Function} (optional)",
                      "name": "callback",
                      "type": "Function",
                      "desc": "(optional)",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise|void} A promise when `callback` is not provided.",
                    "name": "return",
                    "type": "Promise|void",
                    "desc": "A promise when `callback` is not provided."
                  }
                }
              ],
              "desc": "<p>Starts a connection to the client's origin and tunnels a connection through it,\nas defined by [<code>dispatcher.connect()</code>][].</p>"
            },
            {
              "textRaw": "`client.dispatch(options, handlers)`",
              "name": "dispatch",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "handlers"
                    }
                  ]
                }
              ],
              "desc": "<p>Implements [<code>dispatcher.dispatch(options, handler)</code>][]. This is the lowest-level\nAPI used by all other request methods; prefer <code>client.request()</code> for most use\ncases.</p>"
            },
            {
              "textRaw": "`client.pipeline(options, handler)`",
              "name": "pipeline",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "handler"
                    }
                  ]
                }
              ],
              "desc": "<p>See [<code>dispatcher.pipeline(options, handler)</code>][]. Sends a request and returns a\n<a href=\"https://nodejs.org/api/stream.html#class-streamduplex\"><code>&#x3C;Duplex></code></a> stream that the request body is written to and the response body is\nread from.</p>"
            },
            {
              "textRaw": "`client.request(options[, callback])`",
              "name": "request",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object"
                    },
                    {
                      "textRaw": "`callback` {Function} (optional)",
                      "name": "callback",
                      "type": "Function",
                      "desc": "(optional)",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise|void} A promise resolving to the response data when `callback` is not provided.",
                    "name": "return",
                    "type": "Promise|void",
                    "desc": "A promise resolving to the response data when `callback` is not provided."
                  }
                }
              ],
              "desc": "<p>See [<code>dispatcher.request(options[, callback])</code>][]. Performs an HTTP request and\nreturns its status code, headers, trailers, and a readable body stream.</p>\n<pre><code class=\"language-mjs\">import { Client } from 'undici'\n\nconst client = new Client('http://localhost:3000')\nconst { statusCode, headers, body } = await client.request({\n  path: '/',\n  method: 'GET'\n})\n\nconsole.log(statusCode)\nfor await (const chunk of body) {\n  console.log(chunk.toString())\n}\n</code></pre>"
            },
            {
              "textRaw": "`client.stream(options, factory[, callback])`",
              "name": "stream",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object"
                    },
                    {
                      "textRaw": "`factory` {Function} Returns a {Writable} the response body is piped into.",
                      "name": "factory",
                      "type": "Function",
                      "desc": "Returns a {Writable} the response body is piped into."
                    },
                    {
                      "textRaw": "`callback` {Function} (optional)",
                      "name": "callback",
                      "type": "Function",
                      "desc": "(optional)",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise|void} A promise when `callback` is not provided.",
                    "name": "return",
                    "type": "Promise|void",
                    "desc": "A promise when `callback` is not provided."
                  }
                }
              ],
              "desc": "<p>See [<code>dispatcher.stream(options, factory[, callback])</code>][]. A faster alternative\nto <code>client.request()</code> when the destination of the response body is known in\nadvance.</p>"
            },
            {
              "textRaw": "`client.upgrade(options[, callback])`",
              "name": "upgrade",
              "type": "method",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object"
                    },
                    {
                      "textRaw": "`callback` {Function} (optional)",
                      "name": "callback",
                      "type": "Function",
                      "desc": "(optional)",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Promise|void} A promise when `callback` is not provided.",
                    "name": "return",
                    "type": "Promise|void",
                    "desc": "A promise when `callback` is not provided."
                  }
                }
              ],
              "desc": "<p>See [<code>dispatcher.upgrade(options[, callback])</code>][]. Upgrades a connection to a\ndifferent protocol, such as for WebSocket or HTTP <code>CONNECT</code>.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {boolean}",
              "name": "closed",
              "type": "boolean",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "desc": "<p><code>true</code> after <code>client.close()</code> has been called.</p>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "destroyed",
              "type": "boolean",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "desc": "<p><code>true</code> after <code>client.destroy()</code> has been called, or after <code>client.close()</code> has\nbeen called and the client shutdown has completed.</p>"
            },
            {
              "textRaw": "Type: {number}",
              "name": "pipelining",
              "type": "number",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "desc": "<p>The pipelining factor. This property can be read and written to adjust the\nnumber of concurrent requests sent over the connection. Only enable pipelining\nwith trusted remote servers.</p>"
            },
            {
              "textRaw": "Type: {ClientStats}",
              "name": "stats",
              "type": "ClientStats",
              "meta": {
                "added": [
                  "v7.9.0"
                ],
                "changes": []
              },
              "desc": "<p>Aggregate statistics for the client. See <a href=\"ClientStats.html\"><code>ClientStats</code></a>.</p>"
            }
          ],
          "events": [
            {
              "textRaw": "Event: `'connect'`",
              "name": "connect",
              "type": "event",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`origin` {URL}",
                  "name": "origin",
                  "type": "URL"
                },
                {
                  "textRaw": "`targets` {Array<Dispatcher>}",
                  "name": "targets",
                  "type": "Array<Dispatcher>"
                }
              ],
              "desc": "<p>Emitted when a socket has been created and connected. The client connects once\n<code>client.size > 0</code>. See <a href=\"Dispatcher.html#event-connect\"><code>Dispatcher</code> Event: <code>'connect'</code></a>.</p>\n<pre><code class=\"language-mjs\">import { createServer } from 'node:http'\nimport { Client } from 'undici'\nimport { once } from 'node:events'\n\nconst server = createServer((request, response) => {\n  response.end('Hello, World!')\n}).listen()\n\nawait once(server, 'listening')\n\nconst client = new Client(`http://localhost:${server.address().port}`)\n\nclient.on('connect', (origin) => {\n  console.log(`Connected to ${origin}`)\n})\n\nconst { body } = await client.request({ path: '/', method: 'GET' })\nbody.setEncoding('utf8')\nbody.on('data', console.log)\n\nclient.close()\nserver.close()\n</code></pre>"
            },
            {
              "textRaw": "Event: `'disconnect'`",
              "name": "disconnect",
              "type": "event",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": [
                  {
                    "version": "v4.0.0",
                    "pr-url": "https://github.com/nodejs/undici/pull/771",
                    "description": "The event is only emitted if the client had previously connected."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`origin` {URL}",
                  "name": "origin",
                  "type": "URL"
                },
                {
                  "textRaw": "`targets` {Array<Dispatcher>}",
                  "name": "targets",
                  "type": "Array<Dispatcher>"
                },
                {
                  "textRaw": "`error` {Error}",
                  "name": "error",
                  "type": "Error"
                }
              ],
              "desc": "<p>Emitted when a socket has disconnected. The <code>error</code> argument is the error that\ncaused the disconnection. The client reconnects if or once <code>client.size > 0</code>.\nSee <a href=\"Dispatcher.html#event-disconnect\"><code>Dispatcher</code> Event: <code>'disconnect'</code></a>.</p>\n<pre><code class=\"language-mjs\">import { createServer } from 'node:http'\nimport { Client } from 'undici'\nimport { once } from 'node:events'\n\nconst server = createServer((request, response) => {\n  response.destroy()\n}).listen()\n\nawait once(server, 'listening')\n\nconst client = new Client(`http://localhost:${server.address().port}`)\n\nclient.on('disconnect', (origin) => {\n  console.log(`Disconnected from ${origin}`)\n})\n\ntry {\n  await client.request({ path: '/', method: 'GET' })\n} catch (error) {\n  console.error(error.message)\n} finally {\n  client.close()\n  server.close()\n}\n</code></pre>"
            },
            {
              "textRaw": "Event: `'drain'`",
              "name": "drain",
              "type": "event",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`origin` {URL}",
                  "name": "origin",
                  "type": "URL"
                }
              ],
              "desc": "<p>Emitted when the pipeline is no longer busy. See\n<a href=\"Dispatcher.html#event-drain\"><code>Dispatcher</code> Event: <code>'drain'</code></a>.</p>\n<pre><code class=\"language-mjs\">import { createServer } from 'node:http'\nimport { Client } from 'undici'\nimport { once } from 'node:events'\n\nconst server = createServer((request, response) => {\n  response.end('Hello, World!')\n}).listen()\n\nawait once(server, 'listening')\n\nconst client = new Client(`http://localhost:${server.address().port}`)\n\nclient.on('drain', () => {\n  console.log('drain event')\n  client.close()\n  server.close()\n})\n\nawait Promise.all([\n  client.request({ path: '/', method: 'GET' }),\n  client.request({ path: '/', method: 'GET' }),\n  client.request({ path: '/', method: 'GET' })\n])\n</code></pre>"
            },
            {
              "textRaw": "Event: `'error'`",
              "name": "error",
              "type": "event",
              "meta": {
                "added": [
                  "v1.0.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`error` {Error}",
                  "name": "error",
                  "type": "Error"
                }
              ],
              "desc": "<p>Emitted for user errors, such as throwing inside an <code>onResponseError</code> handler.</p>\n<p>[<code>dispatcher.close([callback])</code>]: Dispatcher.md#dispatcherclosecallback\n[<code>dispatcher.connect()</code>]: Dispatcher.md#dispatcherconnectoptions-callback\n[<code>dispatcher.destroy([error[, callback]])</code>]: Dispatcher.md#dispatcherdestroyerror-callback\n[<code>dispatcher.dispatch(options, handler)</code>]: Dispatcher.md#dispatcherdispatchoptions-handler\n[<code>dispatcher.pipeline(options, handler)</code>]: Dispatcher.md#dispatcherpipelineoptions-handler\n[<code>dispatcher.request(options[, callback])</code>]: Dispatcher.md#dispatcherrequestoptions-callback\n[<code>dispatcher.stream(options, factory[, callback])</code>]: Dispatcher.md#dispatcherstreamoptions-factory-callback\n[<code>dispatcher.upgrade(options[, callback])</code>]: Dispatcher.md#dispatcherupgradeoptions-callback\n[<code>tls.connect()</code>]: <a href=\"https://nodejs.org/api/tls.html#tlsconnectoptions-callback\">https://nodejs.org/api/tls.html#tlsconnectoptions-callback</a></p>"
            }
          ]
        }
      ]
    }
  ]
}