@idlebox/stripe-node-types 24.0.14-patch.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +16 -0
  3. package/assert/strict.d.ts +5 -0
  4. package/assert.d.ts +1053 -0
  5. package/async_hooks.d.ts +621 -0
  6. package/buffer.buffer.d.ts +464 -0
  7. package/buffer.d.ts +1928 -0
  8. package/child_process.d.ts +1547 -0
  9. package/cluster.d.ts +576 -0
  10. package/compatibility/iterators.d.ts +22 -0
  11. package/console.d.ts +449 -0
  12. package/constants.d.ts +18 -0
  13. package/crypto.d.ts +4514 -0
  14. package/dgram.d.ts +597 -0
  15. package/diagnostics_channel.d.ts +576 -0
  16. package/dns/promises.d.ts +501 -0
  17. package/dns.d.ts +916 -0
  18. package/dom-events.d.ts +100 -0
  19. package/domain.d.ts +168 -0
  20. package/events.d.ts +927 -0
  21. package/fs/promises.d.ts +1278 -0
  22. package/fs.d.ts +4444 -0
  23. package/globals.d.ts +368 -0
  24. package/globals.typedarray.d.ts +23 -0
  25. package/http.d.ts +2044 -0
  26. package/http2.d.ts +2626 -0
  27. package/https.d.ts +543 -0
  28. package/index.d.ts +96 -0
  29. package/inspector.d.ts +3993 -0
  30. package/module.d.ts +866 -0
  31. package/my-shim.d.ts +57 -0
  32. package/net.d.ts +1030 -0
  33. package/os.d.ts +494 -0
  34. package/package.json +158 -0
  35. package/path.d.ts +189 -0
  36. package/perf_hooks.d.ts +968 -0
  37. package/process.d.ts +2016 -0
  38. package/punycode.d.ts +115 -0
  39. package/querystring.d.ts +150 -0
  40. package/readline/promises.d.ts +159 -0
  41. package/readline.d.ts +592 -0
  42. package/repl.d.ts +426 -0
  43. package/sea.d.ts +154 -0
  44. package/sqlite.d.ts +689 -0
  45. package/stream/consumers.d.ts +36 -0
  46. package/stream/promises.d.ts +88 -0
  47. package/stream/web.d.ts +616 -0
  48. package/stream.d.ts +1654 -0
  49. package/string_decoder.d.ts +65 -0
  50. package/test.d.ts +2216 -0
  51. package/timers/promises.d.ts +106 -0
  52. package/timers.d.ts +285 -0
  53. package/tls.d.ts +1211 -0
  54. package/trace_events.d.ts +195 -0
  55. package/ts5.1/compatibility/disposable.d.ts +13 -0
  56. package/ts5.1/index.d.ts +100 -0
  57. package/ts5.6/buffer.buffer.d.ts +461 -0
  58. package/ts5.6/compatibility/float16array.d.ts +72 -0
  59. package/ts5.6/globals.typedarray.d.ts +21 -0
  60. package/ts5.6/index.d.ts +98 -0
  61. package/ts5.7/compatibility/float16array.d.ts +73 -0
  62. package/ts5.7/index.d.ts +98 -0
  63. package/tty.d.ts +206 -0
  64. package/undici-types/LICENSE +22 -0
  65. package/undici-types/README.md +7 -0
  66. package/undici-types/agent.d.ts +32 -0
  67. package/undici-types/api.d.ts +44 -0
  68. package/undici-types/balanced-pool.d.ts +30 -0
  69. package/undici-types/cache-interceptor.d.ts +173 -0
  70. package/undici-types/cache.d.ts +37 -0
  71. package/undici-types/client.d.ts +108 -0
  72. package/undici-types/connector.d.ts +35 -0
  73. package/undici-types/content-type.d.ts +22 -0
  74. package/undici-types/cookies.d.ts +31 -0
  75. package/undici-types/diagnostics-channel.d.ts +67 -0
  76. package/undici-types/dispatcher.d.ts +282 -0
  77. package/undici-types/env-http-proxy-agent.d.ts +22 -0
  78. package/undici-types/errors.d.ts +172 -0
  79. package/undici-types/eventsource.d.ts +62 -0
  80. package/undici-types/fetch.d.ts +211 -0
  81. package/undici-types/formdata.d.ts +109 -0
  82. package/undici-types/global-dispatcher.d.ts +10 -0
  83. package/undici-types/global-origin.d.ts +8 -0
  84. package/undici-types/h2c-client.d.ts +76 -0
  85. package/undici-types/handlers.d.ts +16 -0
  86. package/undici-types/header.d.ts +161 -0
  87. package/undici-types/index.d.ts +76 -0
  88. package/undici-types/interceptors.d.ts +35 -0
  89. package/undici-types/mock-agent.d.ts +66 -0
  90. package/undici-types/mock-call-history.d.ts +112 -0
  91. package/undici-types/mock-client.d.ts +26 -0
  92. package/undici-types/mock-errors.d.ts +13 -0
  93. package/undici-types/mock-interceptor.d.ts +94 -0
  94. package/undici-types/mock-pool.d.ts +26 -0
  95. package/undici-types/package.json +55 -0
  96. package/undici-types/patch.d.ts +30 -0
  97. package/undici-types/pool-stats.d.ts +20 -0
  98. package/undici-types/pool.d.ts +40 -0
  99. package/undici-types/proxy-agent.d.ts +29 -0
  100. package/undici-types/readable.d.ts +69 -0
  101. package/undici-types/retry-agent.d.ts +9 -0
  102. package/undici-types/retry-handler.d.ts +117 -0
  103. package/undici-types/util.d.ts +19 -0
  104. package/undici-types/utility.d.ts +8 -0
  105. package/undici-types/webidl.d.ts +267 -0
  106. package/undici-types/websocket.d.ts +185 -0
  107. package/url.d.ts +1012 -0
  108. package/util.d.ts +2300 -0
  109. package/v8.d.ts +917 -0
  110. package/vm.d.ts +1034 -0
  111. package/wasi.d.ts +179 -0
  112. package/worker_threads.d.ts +773 -0
  113. package/zlib.d.ts +666 -0
package/http.d.ts ADDED
@@ -0,0 +1,2044 @@
1
+ /**
2
+ * To use the HTTP server and client one must import the `node:http` module.
3
+ *
4
+ * The HTTP interfaces in Node.js are designed to support many features
5
+ * of the protocol which have been traditionally difficult to use.
6
+ * In particular, large, possibly chunk-encoded, messages. The interface is
7
+ * careful to never buffer entire requests or responses, so the
8
+ * user is able to stream data.
9
+ *
10
+ * HTTP message headers are represented by an object like this:
11
+ *
12
+ * ```json
13
+ * { "content-length": "123",
14
+ * "content-type": "text/plain",
15
+ * "connection": "keep-alive",
16
+ * "host": "example.com",
17
+ * "accept": "*" }
18
+ * ```
19
+ *
20
+ * Keys are lowercased. Values are not modified.
21
+ *
22
+ * In order to support the full spectrum of possible HTTP applications, the Node.js
23
+ * HTTP API is very low-level. It deals with stream handling and message
24
+ * parsing only. It parses a message into headers and body but it does not
25
+ * parse the actual headers or the body.
26
+ *
27
+ * See `message.headers` for details on how duplicate headers are handled.
28
+ *
29
+ * The raw headers as they were received are retained in the `rawHeaders` property, which is an array of `[key, value, key2, value2, ...]`. For
30
+ * example, the previous message header object might have a `rawHeaders` list like the following:
31
+ *
32
+ * ```js
33
+ * [ 'ConTent-Length', '123456',
34
+ * 'content-LENGTH', '123',
35
+ * 'content-type', 'text/plain',
36
+ * 'CONNECTION', 'keep-alive',
37
+ * 'Host', 'example.com',
38
+ * 'accepT', '*' ]
39
+ * ```
40
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/http.js)
41
+ */
42
+
43
+ declare module "node:http" {
44
+ import * as stream from 'node:stream';
45
+ import { URL } from 'node:url';
46
+ import { LookupOptions } from '_not-use-node-type_dns';
47
+ import { EventEmitter } from 'node:events';
48
+ import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from 'node:net';
49
+ // incoming headers will never contain number
50
+ interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
51
+ accept?: string | undefined;
52
+ "accept-encoding"?: string | undefined;
53
+ "accept-language"?: string | undefined;
54
+ "accept-patch"?: string | undefined;
55
+ "accept-ranges"?: string | undefined;
56
+ "access-control-allow-credentials"?: string | undefined;
57
+ "access-control-allow-headers"?: string | undefined;
58
+ "access-control-allow-methods"?: string | undefined;
59
+ "access-control-allow-origin"?: string | undefined;
60
+ "access-control-expose-headers"?: string | undefined;
61
+ "access-control-max-age"?: string | undefined;
62
+ "access-control-request-headers"?: string | undefined;
63
+ "access-control-request-method"?: string | undefined;
64
+ age?: string | undefined;
65
+ allow?: string | undefined;
66
+ "alt-svc"?: string | undefined;
67
+ authorization?: string | undefined;
68
+ "cache-control"?: string | undefined;
69
+ connection?: string | undefined;
70
+ "content-disposition"?: string | undefined;
71
+ "content-encoding"?: string | undefined;
72
+ "content-language"?: string | undefined;
73
+ "content-length"?: string | undefined;
74
+ "content-location"?: string | undefined;
75
+ "content-range"?: string | undefined;
76
+ "content-type"?: string | undefined;
77
+ cookie?: string | undefined;
78
+ date?: string | undefined;
79
+ etag?: string | undefined;
80
+ expect?: string | undefined;
81
+ expires?: string | undefined;
82
+ forwarded?: string | undefined;
83
+ from?: string | undefined;
84
+ host?: string | undefined;
85
+ "if-match"?: string | undefined;
86
+ "if-modified-since"?: string | undefined;
87
+ "if-none-match"?: string | undefined;
88
+ "if-unmodified-since"?: string | undefined;
89
+ "last-modified"?: string | undefined;
90
+ location?: string | undefined;
91
+ origin?: string | undefined;
92
+ pragma?: string | undefined;
93
+ "proxy-authenticate"?: string | undefined;
94
+ "proxy-authorization"?: string | undefined;
95
+ "public-key-pins"?: string | undefined;
96
+ range?: string | undefined;
97
+ referer?: string | undefined;
98
+ "retry-after"?: string | undefined;
99
+ "sec-fetch-site"?: string | undefined;
100
+ "sec-fetch-mode"?: string | undefined;
101
+ "sec-fetch-user"?: string | undefined;
102
+ "sec-fetch-dest"?: string | undefined;
103
+ "sec-websocket-accept"?: string | undefined;
104
+ "sec-websocket-extensions"?: string | undefined;
105
+ "sec-websocket-key"?: string | undefined;
106
+ "sec-websocket-protocol"?: string | undefined;
107
+ "sec-websocket-version"?: string | undefined;
108
+ "set-cookie"?: string[] | undefined;
109
+ "strict-transport-security"?: string | undefined;
110
+ tk?: string | undefined;
111
+ trailer?: string | undefined;
112
+ "transfer-encoding"?: string | undefined;
113
+ upgrade?: string | undefined;
114
+ "user-agent"?: string | undefined;
115
+ vary?: string | undefined;
116
+ via?: string | undefined;
117
+ warning?: string | undefined;
118
+ "www-authenticate"?: string | undefined;
119
+ }
120
+ // outgoing headers allows numbers (as they are converted internally to strings)
121
+ type OutgoingHttpHeader = number | string | string[];
122
+ interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {
123
+ accept?: string | string[] | undefined;
124
+ "accept-charset"?: string | string[] | undefined;
125
+ "accept-encoding"?: string | string[] | undefined;
126
+ "accept-language"?: string | string[] | undefined;
127
+ "accept-ranges"?: string | undefined;
128
+ "access-control-allow-credentials"?: string | undefined;
129
+ "access-control-allow-headers"?: string | undefined;
130
+ "access-control-allow-methods"?: string | undefined;
131
+ "access-control-allow-origin"?: string | undefined;
132
+ "access-control-expose-headers"?: string | undefined;
133
+ "access-control-max-age"?: string | undefined;
134
+ "access-control-request-headers"?: string | undefined;
135
+ "access-control-request-method"?: string | undefined;
136
+ age?: string | undefined;
137
+ allow?: string | undefined;
138
+ authorization?: string | undefined;
139
+ "cache-control"?: string | undefined;
140
+ "cdn-cache-control"?: string | undefined;
141
+ connection?: string | string[] | undefined;
142
+ "content-disposition"?: string | undefined;
143
+ "content-encoding"?: string | undefined;
144
+ "content-language"?: string | undefined;
145
+ "content-length"?: string | number | undefined;
146
+ "content-location"?: string | undefined;
147
+ "content-range"?: string | undefined;
148
+ "content-security-policy"?: string | undefined;
149
+ "content-security-policy-report-only"?: string | undefined;
150
+ "content-type"?: string | undefined;
151
+ cookie?: string | string[] | undefined;
152
+ dav?: string | string[] | undefined;
153
+ dnt?: string | undefined;
154
+ date?: string | undefined;
155
+ etag?: string | undefined;
156
+ expect?: string | undefined;
157
+ expires?: string | undefined;
158
+ forwarded?: string | undefined;
159
+ from?: string | undefined;
160
+ host?: string | undefined;
161
+ "if-match"?: string | undefined;
162
+ "if-modified-since"?: string | undefined;
163
+ "if-none-match"?: string | undefined;
164
+ "if-range"?: string | undefined;
165
+ "if-unmodified-since"?: string | undefined;
166
+ "last-modified"?: string | undefined;
167
+ link?: string | string[] | undefined;
168
+ location?: string | undefined;
169
+ "max-forwards"?: string | undefined;
170
+ origin?: string | undefined;
171
+ pragma?: string | string[] | undefined;
172
+ "proxy-authenticate"?: string | string[] | undefined;
173
+ "proxy-authorization"?: string | undefined;
174
+ "public-key-pins"?: string | undefined;
175
+ "public-key-pins-report-only"?: string | undefined;
176
+ range?: string | undefined;
177
+ referer?: string | undefined;
178
+ "referrer-policy"?: string | undefined;
179
+ refresh?: string | undefined;
180
+ "retry-after"?: string | undefined;
181
+ "sec-websocket-accept"?: string | undefined;
182
+ "sec-websocket-extensions"?: string | string[] | undefined;
183
+ "sec-websocket-key"?: string | undefined;
184
+ "sec-websocket-protocol"?: string | string[] | undefined;
185
+ "sec-websocket-version"?: string | undefined;
186
+ server?: string | undefined;
187
+ "set-cookie"?: string | string[] | undefined;
188
+ "strict-transport-security"?: string | undefined;
189
+ te?: string | undefined;
190
+ trailer?: string | undefined;
191
+ "transfer-encoding"?: string | undefined;
192
+ "user-agent"?: string | undefined;
193
+ upgrade?: string | undefined;
194
+ "upgrade-insecure-requests"?: string | undefined;
195
+ vary?: string | undefined;
196
+ via?: string | string[] | undefined;
197
+ warning?: string | undefined;
198
+ "www-authenticate"?: string | string[] | undefined;
199
+ "x-content-type-options"?: string | undefined;
200
+ "x-dns-prefetch-control"?: string | undefined;
201
+ "x-frame-options"?: string | undefined;
202
+ "x-xss-protection"?: string | undefined;
203
+ }
204
+ interface ClientRequestArgs {
205
+ _defaultAgent?: Agent | undefined;
206
+ agent?: Agent | boolean | undefined;
207
+ auth?: string | null | undefined;
208
+ createConnection?:
209
+ | ((
210
+ options: ClientRequestArgs,
211
+ oncreate: (err: Error | null, socket: stream.Duplex) => void,
212
+ ) => stream.Duplex | null | undefined)
213
+ | undefined;
214
+ defaultPort?: number | string | undefined;
215
+ family?: number | undefined;
216
+ headers?: OutgoingHttpHeaders | readonly string[] | undefined;
217
+ hints?: LookupOptions["hints"];
218
+ host?: string | null | undefined;
219
+ hostname?: string | null | undefined;
220
+ insecureHTTPParser?: boolean | undefined;
221
+ localAddress?: string | undefined;
222
+ localPort?: number | undefined;
223
+ lookup?: LookupFunction | undefined;
224
+ /**
225
+ * @default 16384
226
+ */
227
+ maxHeaderSize?: number | undefined;
228
+ method?: string | undefined;
229
+ path?: string | null | undefined;
230
+ port?: number | string | null | undefined;
231
+ protocol?: string | null | undefined;
232
+ setDefaultHeaders?: boolean | undefined;
233
+ setHost?: boolean | undefined;
234
+ signal?: AbortSignal | undefined;
235
+ socketPath?: string | undefined;
236
+ timeout?: number | undefined;
237
+ uniqueHeaders?: Array<string | string[]> | undefined;
238
+ joinDuplicateHeaders?: boolean;
239
+ }
240
+ interface ServerOptions<
241
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
242
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
243
+ > {
244
+ /**
245
+ * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
246
+ */
247
+ IncomingMessage?: Request | undefined;
248
+ /**
249
+ * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`.
250
+ */
251
+ ServerResponse?: Response | undefined;
252
+ /**
253
+ * Sets the timeout value in milliseconds for receiving the entire request from the client.
254
+ * @see Server.requestTimeout for more information.
255
+ * @default 300000
256
+ * @since v18.0.0
257
+ */
258
+ requestTimeout?: number | undefined;
259
+ /**
260
+ * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates.
261
+ * @default false
262
+ * @since v18.14.0
263
+ */
264
+ joinDuplicateHeaders?: boolean;
265
+ /**
266
+ * The number of milliseconds of inactivity a server needs to wait for additional incoming data,
267
+ * after it has finished writing the last response, before a socket will be destroyed.
268
+ * @see Server.keepAliveTimeout for more information.
269
+ * @default 5000
270
+ * @since v18.0.0
271
+ */
272
+ keepAliveTimeout?: number | undefined;
273
+ /**
274
+ * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
275
+ * @default 30000
276
+ */
277
+ connectionsCheckingInterval?: number | undefined;
278
+ /**
279
+ * Sets the timeout value in milliseconds for receiving the complete HTTP headers from the client.
280
+ * See {@link Server.headersTimeout} for more information.
281
+ * @default 60000
282
+ * @since 18.0.0
283
+ */
284
+ headersTimeout?: number | undefined;
285
+ /**
286
+ * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
287
+ * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`.
288
+ * Default: @see stream.getDefaultHighWaterMark().
289
+ * @since v20.1.0
290
+ */
291
+ highWaterMark?: number | undefined;
292
+ /**
293
+ * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`.
294
+ * Using the insecure parser should be avoided.
295
+ * See --insecure-http-parser for more information.
296
+ * @default false
297
+ */
298
+ insecureHTTPParser?: boolean | undefined;
299
+ /**
300
+ * Optionally overrides the value of `--max-http-header-size` for requests received by
301
+ * this server, i.e. the maximum length of request headers in bytes.
302
+ * @default 16384
303
+ * @since v13.3.0
304
+ */
305
+ maxHeaderSize?: number | undefined;
306
+ /**
307
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
308
+ * @default true
309
+ * @since v16.5.0
310
+ */
311
+ noDelay?: boolean | undefined;
312
+ /**
313
+ * If set to `true`, it forces the server to respond with a 400 (Bad Request) status code
314
+ * to any HTTP/1.1 request message that lacks a Host header (as mandated by the specification).
315
+ * @default true
316
+ * @since 20.0.0
317
+ */
318
+ requireHostHeader?: boolean | undefined;
319
+ /**
320
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
321
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
322
+ * @default false
323
+ * @since v16.5.0
324
+ */
325
+ keepAlive?: boolean | undefined;
326
+ /**
327
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
328
+ * @default 0
329
+ * @since v16.5.0
330
+ */
331
+ keepAliveInitialDelay?: number | undefined;
332
+ /**
333
+ * A list of response headers that should be sent only once.
334
+ * If the header's value is an array, the items will be joined using `; `.
335
+ */
336
+ uniqueHeaders?: Array<string | string[]> | undefined;
337
+ /**
338
+ * If set to `true`, an error is thrown when writing to an HTTP response which does not have a body.
339
+ * @default false
340
+ * @since v18.17.0, v20.2.0
341
+ */
342
+ rejectNonStandardBodyWrites?: boolean | undefined;
343
+ }
344
+ type RequestListener<
345
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
346
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
347
+ > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
348
+ /**
349
+ * @since v0.1.17
350
+ */
351
+ class Server<
352
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
353
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
354
+ > extends NetServer {
355
+ constructor(requestListener?: RequestListener<Request, Response>);
356
+ constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
357
+ /**
358
+ * Sets the timeout value for sockets, and emits a `'timeout'` event on
359
+ * the Server object, passing the socket as an argument, if a timeout
360
+ * occurs.
361
+ *
362
+ * If there is a `'timeout'` event listener on the Server object, then it
363
+ * will be called with the timed-out socket as an argument.
364
+ *
365
+ * By default, the Server does not timeout sockets. However, if a callback
366
+ * is assigned to the Server's `'timeout'` event, timeouts must be handled
367
+ * explicitly.
368
+ * @since v0.9.12
369
+ * @param [msecs=0 (no timeout)]
370
+ */
371
+ setTimeout(msecs?: number, callback?: (socket: Socket) => void): this;
372
+ setTimeout(callback: (socket: Socket) => void): this;
373
+ /**
374
+ * Limits maximum incoming headers count. If set to 0, no limit will be applied.
375
+ * @since v0.7.0
376
+ */
377
+ maxHeadersCount: number | null;
378
+ /**
379
+ * The maximum number of requests socket can handle
380
+ * before closing keep alive connection.
381
+ *
382
+ * A value of `0` will disable the limit.
383
+ *
384
+ * When the limit is reached it will set the `Connection` header value to `close`,
385
+ * but will not actually close the connection, subsequent requests sent
386
+ * after the limit is reached will get `503 Service Unavailable` as a response.
387
+ * @since v16.10.0
388
+ */
389
+ maxRequestsPerSocket: number | null;
390
+ /**
391
+ * The number of milliseconds of inactivity before a socket is presumed
392
+ * to have timed out.
393
+ *
394
+ * A value of `0` will disable the timeout behavior on incoming connections.
395
+ *
396
+ * The socket timeout logic is set up on connection, so changing this
397
+ * value only affects new connections to the server, not any existing connections.
398
+ * @since v0.9.12
399
+ */
400
+ timeout: number;
401
+ /**
402
+ * Limit the amount of time the parser will wait to receive the complete HTTP
403
+ * headers.
404
+ *
405
+ * If the timeout expires, the server responds with status 408 without
406
+ * forwarding the request to the request listener and then closes the connection.
407
+ *
408
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
409
+ * potential Denial-of-Service attacks in case the server is deployed without a
410
+ * reverse proxy in front.
411
+ * @since v11.3.0, v10.14.0
412
+ */
413
+ headersTimeout: number;
414
+ /**
415
+ * The number of milliseconds of inactivity a server needs to wait for additional
416
+ * incoming data, after it has finished writing the last response, before a socket
417
+ * will be destroyed. If the server receives new data before the keep-alive
418
+ * timeout has fired, it will reset the regular inactivity timeout, i.e., `server.timeout`.
419
+ *
420
+ * A value of `0` will disable the keep-alive timeout behavior on incoming
421
+ * connections.
422
+ * A value of `0` makes the http server behave similarly to Node.js versions prior
423
+ * to 8.0.0, which did not have a keep-alive timeout.
424
+ *
425
+ * The socket timeout logic is set up on connection, so changing this value only
426
+ * affects new connections to the server, not any existing connections.
427
+ * @since v8.0.0
428
+ */
429
+ keepAliveTimeout: number;
430
+ /**
431
+ * Sets the timeout value in milliseconds for receiving the entire request from
432
+ * the client.
433
+ *
434
+ * If the timeout expires, the server responds with status 408 without
435
+ * forwarding the request to the request listener and then closes the connection.
436
+ *
437
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
438
+ * potential Denial-of-Service attacks in case the server is deployed without a
439
+ * reverse proxy in front.
440
+ * @since v14.11.0
441
+ */
442
+ requestTimeout: number;
443
+ /**
444
+ * Closes all connections connected to this server.
445
+ * @since v18.2.0
446
+ */
447
+ closeAllConnections(): void;
448
+ /**
449
+ * Closes all connections connected to this server which are not sending a request
450
+ * or waiting for a response.
451
+ * @since v18.2.0
452
+ */
453
+ closeIdleConnections(): void;
454
+ addListener(event: string, listener: (...args: any[]) => void): this;
455
+ addListener(event: "close", listener: () => void): this;
456
+ addListener(event: "connection", listener: (socket: Socket) => void): this;
457
+ addListener(event: "error", listener: (err: Error) => void): this;
458
+ addListener(event: "listening", listener: () => void): this;
459
+ addListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
460
+ addListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
461
+ addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
462
+ addListener(
463
+ event: "connect",
464
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
465
+ ): this;
466
+ addListener(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
467
+ addListener(event: "request", listener: RequestListener<Request, Response>): this;
468
+ addListener(
469
+ event: "upgrade",
470
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
471
+ ): this;
472
+ emit(event: string, ...args: any[]): boolean;
473
+ emit(event: "close"): boolean;
474
+ emit(event: "connection", socket: Socket): boolean;
475
+ emit(event: "error", err: Error): boolean;
476
+ emit(event: "listening"): boolean;
477
+ emit(
478
+ event: "checkContinue",
479
+ req: InstanceType<Request>,
480
+ res: InstanceType<Response> & { req: InstanceType<Request> },
481
+ ): boolean;
482
+ emit(
483
+ event: "checkExpectation",
484
+ req: InstanceType<Request>,
485
+ res: InstanceType<Response> & { req: InstanceType<Request> },
486
+ ): boolean;
487
+ emit(event: "clientError", err: Error, socket: stream.Duplex): boolean;
488
+ emit(event: "connect", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
489
+ emit(event: "dropRequest", req: InstanceType<Request>, socket: stream.Duplex): boolean;
490
+ emit(
491
+ event: "request",
492
+ req: InstanceType<Request>,
493
+ res: InstanceType<Response> & { req: InstanceType<Request> },
494
+ ): boolean;
495
+ emit(event: "upgrade", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
496
+ on(event: string, listener: (...args: any[]) => void): this;
497
+ on(event: "close", listener: () => void): this;
498
+ on(event: "connection", listener: (socket: Socket) => void): this;
499
+ on(event: "error", listener: (err: Error) => void): this;
500
+ on(event: "listening", listener: () => void): this;
501
+ on(event: "checkContinue", listener: RequestListener<Request, Response>): this;
502
+ on(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
503
+ on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
504
+ on(event: "connect", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
505
+ on(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
506
+ on(event: "request", listener: RequestListener<Request, Response>): this;
507
+ on(event: "upgrade", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
508
+ once(event: string, listener: (...args: any[]) => void): this;
509
+ once(event: "close", listener: () => void): this;
510
+ once(event: "connection", listener: (socket: Socket) => void): this;
511
+ once(event: "error", listener: (err: Error) => void): this;
512
+ once(event: "listening", listener: () => void): this;
513
+ once(event: "checkContinue", listener: RequestListener<Request, Response>): this;
514
+ once(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
515
+ once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
516
+ once(
517
+ event: "connect",
518
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
519
+ ): this;
520
+ once(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
521
+ once(event: "request", listener: RequestListener<Request, Response>): this;
522
+ once(
523
+ event: "upgrade",
524
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
525
+ ): this;
526
+ prependListener(event: string, listener: (...args: any[]) => void): this;
527
+ prependListener(event: "close", listener: () => void): this;
528
+ prependListener(event: "connection", listener: (socket: Socket) => void): this;
529
+ prependListener(event: "error", listener: (err: Error) => void): this;
530
+ prependListener(event: "listening", listener: () => void): this;
531
+ prependListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
532
+ prependListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
533
+ prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
534
+ prependListener(
535
+ event: "connect",
536
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
537
+ ): this;
538
+ prependListener(
539
+ event: "dropRequest",
540
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
541
+ ): this;
542
+ prependListener(event: "request", listener: RequestListener<Request, Response>): this;
543
+ prependListener(
544
+ event: "upgrade",
545
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
546
+ ): this;
547
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
548
+ prependOnceListener(event: "close", listener: () => void): this;
549
+ prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
550
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
551
+ prependOnceListener(event: "listening", listener: () => void): this;
552
+ prependOnceListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
553
+ prependOnceListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
554
+ prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
555
+ prependOnceListener(
556
+ event: "connect",
557
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
558
+ ): this;
559
+ prependOnceListener(
560
+ event: "dropRequest",
561
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
562
+ ): this;
563
+ prependOnceListener(event: "request", listener: RequestListener<Request, Response>): this;
564
+ prependOnceListener(
565
+ event: "upgrade",
566
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
567
+ ): this;
568
+ }
569
+ /**
570
+ * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
571
+ * the perspective of the participants of an HTTP transaction.
572
+ * @since v0.1.17
573
+ */
574
+ class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
575
+ readonly req: Request;
576
+ chunkedEncoding: boolean;
577
+ shouldKeepAlive: boolean;
578
+ useChunkedEncodingByDefault: boolean;
579
+ sendDate: boolean;
580
+ /**
581
+ * @deprecated Use `writableEnded` instead.
582
+ */
583
+ finished: boolean;
584
+ /**
585
+ * Read-only. `true` if the headers were sent, otherwise `false`.
586
+ * @since v0.9.3
587
+ */
588
+ readonly headersSent: boolean;
589
+ /**
590
+ * Alias of `outgoingMessage.socket`.
591
+ * @since v0.3.0
592
+ * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
593
+ */
594
+ readonly connection: Socket | null;
595
+ /**
596
+ * Reference to the underlying socket. Usually, users will not want to access
597
+ * this property.
598
+ *
599
+ * After calling `outgoingMessage.end()`, this property will be nulled.
600
+ * @since v0.3.0
601
+ */
602
+ readonly socket: Socket | null;
603
+ constructor();
604
+ /**
605
+ * Once a socket is associated with the message and is connected, `socket.setTimeout()` will be called with `msecs` as the first parameter.
606
+ * @since v0.9.12
607
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
608
+ */
609
+ setTimeout(msecs: number, callback?: () => void): this;
610
+ /**
611
+ * Sets a single header value. If the header already exists in the to-be-sent
612
+ * headers, its value will be replaced. Use an array of strings to send multiple
613
+ * headers with the same name.
614
+ * @since v0.4.0
615
+ * @param name Header name
616
+ * @param value Header value
617
+ */
618
+ setHeader(name: string, value: number | string | readonly string[]): this;
619
+ /**
620
+ * Sets multiple header values for implicit headers. headers must be an instance of
621
+ * `Headers` or `Map`, if a header already exists in the to-be-sent headers, its
622
+ * value will be replaced.
623
+ *
624
+ * ```js
625
+ * const headers = new Headers({ foo: 'bar' });
626
+ * outgoingMessage.setHeaders(headers);
627
+ * ```
628
+ *
629
+ * or
630
+ *
631
+ * ```js
632
+ * const headers = new Map([['foo', 'bar']]);
633
+ * outgoingMessage.setHeaders(headers);
634
+ * ```
635
+ *
636
+ * When headers have been set with `outgoingMessage.setHeaders()`, they will be
637
+ * merged with any headers passed to `response.writeHead()`, with the headers passed
638
+ * to `response.writeHead()` given precedence.
639
+ *
640
+ * ```js
641
+ * // Returns content-type = text/plain
642
+ * const server = http.createServer((req, res) => {
643
+ * const headers = new Headers({ 'Content-Type': 'text/html' });
644
+ * res.setHeaders(headers);
645
+ * res.writeHead(200, { 'Content-Type': 'text/plain' });
646
+ * res.end('ok');
647
+ * });
648
+ * ```
649
+ *
650
+ * @since v19.6.0, v18.15.0
651
+ * @param name Header name
652
+ * @param value Header value
653
+ */
654
+ setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
655
+ /**
656
+ * Append a single header value to the header object.
657
+ *
658
+ * If the value is an array, this is equivalent to calling this method multiple
659
+ * times.
660
+ *
661
+ * If there were no previous values for the header, this is equivalent to calling `outgoingMessage.setHeader(name, value)`.
662
+ *
663
+ * Depending of the value of `options.uniqueHeaders` when the client request or the
664
+ * server were created, this will end up in the header being sent multiple times or
665
+ * a single time with values joined using `; `.
666
+ * @since v18.3.0, v16.17.0
667
+ * @param name Header name
668
+ * @param value Header value
669
+ */
670
+ appendHeader(name: string, value: string | readonly string[]): this;
671
+ /**
672
+ * Gets the value of the HTTP header with the given name. If that header is not
673
+ * set, the returned value will be `undefined`.
674
+ * @since v0.4.0
675
+ * @param name Name of header
676
+ */
677
+ getHeader(name: string): number | string | string[] | undefined;
678
+ /**
679
+ * Returns a shallow copy of the current outgoing headers. Since a shallow
680
+ * copy is used, array values may be mutated without additional calls to
681
+ * various header-related HTTP module methods. The keys of the returned
682
+ * object are the header names and the values are the respective header
683
+ * values. All header names are lowercase.
684
+ *
685
+ * The object returned by the `outgoingMessage.getHeaders()` method does
686
+ * not prototypically inherit from the JavaScript `Object`. This means that
687
+ * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
688
+ * and others are not defined and will not work.
689
+ *
690
+ * ```js
691
+ * outgoingMessage.setHeader('Foo', 'bar');
692
+ * outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
693
+ *
694
+ * const headers = outgoingMessage.getHeaders();
695
+ * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
696
+ * ```
697
+ * @since v7.7.0
698
+ */
699
+ getHeaders(): OutgoingHttpHeaders;
700
+ /**
701
+ * Returns an array containing the unique names of the current outgoing headers.
702
+ * All names are lowercase.
703
+ * @since v7.7.0
704
+ */
705
+ getHeaderNames(): string[];
706
+ /**
707
+ * Returns `true` if the header identified by `name` is currently set in the
708
+ * outgoing headers. The header name is case-insensitive.
709
+ *
710
+ * ```js
711
+ * const hasContentType = outgoingMessage.hasHeader('content-type');
712
+ * ```
713
+ * @since v7.7.0
714
+ */
715
+ hasHeader(name: string): boolean;
716
+ /**
717
+ * Removes a header that is queued for implicit sending.
718
+ *
719
+ * ```js
720
+ * outgoingMessage.removeHeader('Content-Encoding');
721
+ * ```
722
+ * @since v0.4.0
723
+ * @param name Header name
724
+ */
725
+ removeHeader(name: string): void;
726
+ /**
727
+ * Adds HTTP trailers (headers but at the end of the message) to the message.
728
+ *
729
+ * Trailers will **only** be emitted if the message is chunked encoded. If not,
730
+ * the trailers will be silently discarded.
731
+ *
732
+ * HTTP requires the `Trailer` header to be sent to emit trailers,
733
+ * with a list of header field names in its value, e.g.
734
+ *
735
+ * ```js
736
+ * message.writeHead(200, { 'Content-Type': 'text/plain',
737
+ * 'Trailer': 'Content-MD5' });
738
+ * message.write(fileData);
739
+ * message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
740
+ * message.end();
741
+ * ```
742
+ *
743
+ * Attempting to set a header field name or value that contains invalid characters
744
+ * will result in a `TypeError` being thrown.
745
+ * @since v0.3.0
746
+ */
747
+ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
748
+ /**
749
+ * Flushes the message headers.
750
+ *
751
+ * For efficiency reason, Node.js normally buffers the message headers
752
+ * until `outgoingMessage.end()` is called or the first chunk of message data
753
+ * is written. It then tries to pack the headers and data into a single TCP
754
+ * packet.
755
+ *
756
+ * It is usually desired (it saves a TCP round-trip), but not when the first
757
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()` bypasses the optimization and kickstarts the message.
758
+ * @since v1.6.0
759
+ */
760
+ flushHeaders(): void;
761
+ }
762
+ /**
763
+ * This object is created internally by an HTTP server, not by the user. It is
764
+ * passed as the second parameter to the `'request'` event.
765
+ * @since v0.1.17
766
+ */
767
+ class ServerResponse<Request extends IncomingMessage = IncomingMessage> extends OutgoingMessage<Request> {
768
+ /**
769
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
770
+ * this property controls the status code that will be sent to the client when
771
+ * the headers get flushed.
772
+ *
773
+ * ```js
774
+ * response.statusCode = 404;
775
+ * ```
776
+ *
777
+ * After response header was sent to the client, this property indicates the
778
+ * status code which was sent out.
779
+ * @since v0.4.0
780
+ */
781
+ statusCode: number;
782
+ /**
783
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
784
+ * this property controls the status message that will be sent to the client when
785
+ * the headers get flushed. If this is left as `undefined` then the standard
786
+ * message for the status code will be used.
787
+ *
788
+ * ```js
789
+ * response.statusMessage = 'Not found';
790
+ * ```
791
+ *
792
+ * After response header was sent to the client, this property indicates the
793
+ * status message which was sent out.
794
+ * @since v0.11.8
795
+ */
796
+ statusMessage: string;
797
+ /**
798
+ * If set to `true`, Node.js will check whether the `Content-Length` header value and the size of the body, in bytes, are equal.
799
+ * Mismatching the `Content-Length` header value will result
800
+ * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
801
+ * @since v18.10.0, v16.18.0
802
+ */
803
+ strictContentLength: boolean;
804
+ constructor(req: Request);
805
+ assignSocket(socket: Socket): void;
806
+ detachSocket(socket: Socket): void;
807
+ /**
808
+ * Sends an HTTP/1.1 100 Continue message to the client, indicating that
809
+ * the request body should be sent. See the `'checkContinue'` event on `Server`.
810
+ * @since v0.3.0
811
+ */
812
+ writeContinue(callback?: () => void): void;
813
+ /**
814
+ * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header,
815
+ * indicating that the user agent can preload/preconnect the linked resources.
816
+ * The `hints` is an object containing the values of headers to be sent with
817
+ * early hints message. The optional `callback` argument will be called when
818
+ * the response message has been written.
819
+ *
820
+ * **Example**
821
+ *
822
+ * ```js
823
+ * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
824
+ * response.writeEarlyHints({
825
+ * 'link': earlyHintsLink,
826
+ * });
827
+ *
828
+ * const earlyHintsLinks = [
829
+ * '</styles.css>; rel=preload; as=style',
830
+ * '</scripts.js>; rel=preload; as=script',
831
+ * ];
832
+ * response.writeEarlyHints({
833
+ * 'link': earlyHintsLinks,
834
+ * 'x-trace-id': 'id for diagnostics',
835
+ * });
836
+ *
837
+ * const earlyHintsCallback = () => console.log('early hints message sent');
838
+ * response.writeEarlyHints({
839
+ * 'link': earlyHintsLinks,
840
+ * }, earlyHintsCallback);
841
+ * ```
842
+ * @since v18.11.0
843
+ * @param hints An object containing the values of headers
844
+ * @param callback Will be called when the response message has been written
845
+ */
846
+ writeEarlyHints(hints: Record<string, string | string[]>, callback?: () => void): void;
847
+ /**
848
+ * Sends a response header to the request. The status code is a 3-digit HTTP
849
+ * status code, like `404`. The last argument, `headers`, are the response headers.
850
+ * Optionally one can give a human-readable `statusMessage` as the second
851
+ * argument.
852
+ *
853
+ * `headers` may be an `Array` where the keys and values are in the same list.
854
+ * It is _not_ a list of tuples. So, the even-numbered offsets are key values,
855
+ * and the odd-numbered offsets are the associated values. The array is in the same
856
+ * format as `request.rawHeaders`.
857
+ *
858
+ * Returns a reference to the `ServerResponse`, so that calls can be chained.
859
+ *
860
+ * ```js
861
+ * const body = 'hello world';
862
+ * response
863
+ * .writeHead(200, {
864
+ * 'Content-Length': Buffer.byteLength(body),
865
+ * 'Content-Type': 'text/plain',
866
+ * })
867
+ * .end(body);
868
+ * ```
869
+ *
870
+ * This method must only be called once on a message and it must
871
+ * be called before `response.end()` is called.
872
+ *
873
+ * If `response.write()` or `response.end()` are called before calling
874
+ * this, the implicit/mutable headers will be calculated and call this function.
875
+ *
876
+ * When headers have been set with `response.setHeader()`, they will be merged
877
+ * with any headers passed to `response.writeHead()`, with the headers passed
878
+ * to `response.writeHead()` given precedence.
879
+ *
880
+ * If this method is called and `response.setHeader()` has not been called,
881
+ * it will directly write the supplied header values onto the network channel
882
+ * without caching internally, and the `response.getHeader()` on the header
883
+ * will not yield the expected result. If progressive population of headers is
884
+ * desired with potential future retrieval and modification, use `response.setHeader()` instead.
885
+ *
886
+ * ```js
887
+ * // Returns content-type = text/plain
888
+ * const server = http.createServer((req, res) => {
889
+ * res.setHeader('Content-Type', 'text/html');
890
+ * res.setHeader('X-Foo', 'bar');
891
+ * res.writeHead(200, { 'Content-Type': 'text/plain' });
892
+ * res.end('ok');
893
+ * });
894
+ * ```
895
+ *
896
+ * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
897
+ * will check whether `Content-Length` and the length of the body which has
898
+ * been transmitted are equal or not.
899
+ *
900
+ * Attempting to set a header field name or value that contains invalid characters
901
+ * will result in a \[`Error`\]\[\] being thrown.
902
+ * @since v0.1.30
903
+ */
904
+ writeHead(
905
+ statusCode: number,
906
+ statusMessage?: string,
907
+ headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
908
+ ): this;
909
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
910
+ /**
911
+ * Sends a HTTP/1.1 102 Processing message to the client, indicating that
912
+ * the request body should be sent.
913
+ * @since v10.0.0
914
+ */
915
+ writeProcessing(): void;
916
+ }
917
+ interface InformationEvent {
918
+ statusCode: number;
919
+ statusMessage: string;
920
+ httpVersion: string;
921
+ httpVersionMajor: number;
922
+ httpVersionMinor: number;
923
+ headers: IncomingHttpHeaders;
924
+ rawHeaders: string[];
925
+ }
926
+ /**
927
+ * This object is created internally and returned from {@link request}. It
928
+ * represents an _in-progress_ request whose header has already been queued. The
929
+ * header is still mutable using the `setHeader(name, value)`, `getHeader(name)`, `removeHeader(name)` API. The actual header will
930
+ * be sent along with the first data chunk or when calling `request.end()`.
931
+ *
932
+ * To get the response, add a listener for `'response'` to the request object. `'response'` will be emitted from the request object when the response
933
+ * headers have been received. The `'response'` event is executed with one
934
+ * argument which is an instance of {@link IncomingMessage}.
935
+ *
936
+ * During the `'response'` event, one can add listeners to the
937
+ * response object; particularly to listen for the `'data'` event.
938
+ *
939
+ * If no `'response'` handler is added, then the response will be
940
+ * entirely discarded. However, if a `'response'` event handler is added,
941
+ * then the data from the response object **must** be consumed, either by
942
+ * calling `response.read()` whenever there is a `'readable'` event, or
943
+ * by adding a `'data'` handler, or by calling the `.resume()` method.
944
+ * Until the data is consumed, the `'end'` event will not fire. Also, until
945
+ * the data is read it will consume memory that can eventually lead to a
946
+ * 'process out of memory' error.
947
+ *
948
+ * For backward compatibility, `res` will only emit `'error'` if there is an `'error'` listener registered.
949
+ *
950
+ * Set `Content-Length` header to limit the response body size.
951
+ * If `response.strictContentLength` is set to `true`, mismatching the `Content-Length` header value will result in an `Error` being thrown,
952
+ * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
953
+ *
954
+ * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
955
+ * @since v0.1.17
956
+ */
957
+ class ClientRequest extends OutgoingMessage {
958
+ /**
959
+ * The `request.aborted` property will be `true` if the request has
960
+ * been aborted.
961
+ * @since v0.11.14
962
+ * @deprecated Since v17.0.0, v16.12.0 - Check `destroyed` instead.
963
+ */
964
+ aborted: boolean;
965
+ /**
966
+ * The request host.
967
+ * @since v14.5.0, v12.19.0
968
+ */
969
+ host: string;
970
+ /**
971
+ * The request protocol.
972
+ * @since v14.5.0, v12.19.0
973
+ */
974
+ protocol: string;
975
+ /**
976
+ * When sending request through a keep-alive enabled agent, the underlying socket
977
+ * might be reused. But if server closes connection at unfortunate time, client
978
+ * may run into a 'ECONNRESET' error.
979
+ *
980
+ * ```js
981
+ * import http from 'node:http';
982
+ *
983
+ * // Server has a 5 seconds keep-alive timeout by default
984
+ * http
985
+ * .createServer((req, res) => {
986
+ * res.write('hello\n');
987
+ * res.end();
988
+ * })
989
+ * .listen(3000);
990
+ *
991
+ * setInterval(() => {
992
+ * // Adapting a keep-alive agent
993
+ * http.get('http://localhost:3000', { agent }, (res) => {
994
+ * res.on('data', (data) => {
995
+ * // Do nothing
996
+ * });
997
+ * });
998
+ * }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
999
+ * ```
1000
+ *
1001
+ * By marking a request whether it reused socket or not, we can do
1002
+ * automatic error retry base on it.
1003
+ *
1004
+ * ```js
1005
+ * import http from 'node:http';
1006
+ * const agent = new http.Agent({ keepAlive: true });
1007
+ *
1008
+ * function retriableRequest() {
1009
+ * const req = http
1010
+ * .get('http://localhost:3000', { agent }, (res) => {
1011
+ * // ...
1012
+ * })
1013
+ * .on('error', (err) => {
1014
+ * // Check if retry is needed
1015
+ * if (req.reusedSocket &#x26;&#x26; err.code === 'ECONNRESET') {
1016
+ * retriableRequest();
1017
+ * }
1018
+ * });
1019
+ * }
1020
+ *
1021
+ * retriableRequest();
1022
+ * ```
1023
+ * @since v13.0.0, v12.16.0
1024
+ */
1025
+ reusedSocket: boolean;
1026
+ /**
1027
+ * Limits maximum response headers count. If set to 0, no limit will be applied.
1028
+ */
1029
+ maxHeadersCount: number;
1030
+ constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
1031
+ /**
1032
+ * The request method.
1033
+ * @since v0.1.97
1034
+ */
1035
+ method: string;
1036
+ /**
1037
+ * The request path.
1038
+ * @since v0.4.0
1039
+ */
1040
+ path: string;
1041
+ /**
1042
+ * Marks the request as aborting. Calling this will cause remaining data
1043
+ * in the response to be dropped and the socket to be destroyed.
1044
+ * @since v0.3.8
1045
+ * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead.
1046
+ */
1047
+ abort(): void;
1048
+ onSocket(socket: Socket): void;
1049
+ /**
1050
+ * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called.
1051
+ * @since v0.5.9
1052
+ * @param timeout Milliseconds before a request times out.
1053
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event.
1054
+ */
1055
+ setTimeout(timeout: number, callback?: () => void): this;
1056
+ /**
1057
+ * Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called.
1058
+ * @since v0.5.9
1059
+ */
1060
+ setNoDelay(noDelay?: boolean): void;
1061
+ /**
1062
+ * Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called.
1063
+ * @since v0.5.9
1064
+ */
1065
+ setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
1066
+ /**
1067
+ * Returns an array containing the unique names of the current outgoing raw
1068
+ * headers. Header names are returned with their exact casing being set.
1069
+ *
1070
+ * ```js
1071
+ * request.setHeader('Foo', 'bar');
1072
+ * request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
1073
+ *
1074
+ * const headerNames = request.getRawHeaderNames();
1075
+ * // headerNames === ['Foo', 'Set-Cookie']
1076
+ * ```
1077
+ * @since v15.13.0, v14.17.0
1078
+ */
1079
+ getRawHeaderNames(): string[];
1080
+ /**
1081
+ * @deprecated
1082
+ */
1083
+ addListener(event: "abort", listener: () => void): this;
1084
+ addListener(
1085
+ event: "connect",
1086
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1087
+ ): this;
1088
+ addListener(event: "continue", listener: () => void): this;
1089
+ addListener(event: "information", listener: (info: InformationEvent) => void): this;
1090
+ addListener(event: "response", listener: (response: IncomingMessage) => void): this;
1091
+ addListener(event: "socket", listener: (socket: Socket) => void): this;
1092
+ addListener(event: "timeout", listener: () => void): this;
1093
+ addListener(
1094
+ event: "upgrade",
1095
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1096
+ ): this;
1097
+ addListener(event: "close", listener: () => void): this;
1098
+ addListener(event: "drain", listener: () => void): this;
1099
+ addListener(event: "error", listener: (err: Error) => void): this;
1100
+ addListener(event: "finish", listener: () => void): this;
1101
+ addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1102
+ addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1103
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1104
+ /**
1105
+ * @deprecated
1106
+ */
1107
+ on(event: "abort", listener: () => void): this;
1108
+ on(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1109
+ on(event: "continue", listener: () => void): this;
1110
+ on(event: "information", listener: (info: InformationEvent) => void): this;
1111
+ on(event: "response", listener: (response: IncomingMessage) => void): this;
1112
+ on(event: "socket", listener: (socket: Socket) => void): this;
1113
+ on(event: "timeout", listener: () => void): this;
1114
+ on(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1115
+ on(event: "close", listener: () => void): this;
1116
+ on(event: "drain", listener: () => void): this;
1117
+ on(event: "error", listener: (err: Error) => void): this;
1118
+ on(event: "finish", listener: () => void): this;
1119
+ on(event: "pipe", listener: (src: stream.Readable) => void): this;
1120
+ on(event: "unpipe", listener: (src: stream.Readable) => void): this;
1121
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1122
+ /**
1123
+ * @deprecated
1124
+ */
1125
+ once(event: "abort", listener: () => void): this;
1126
+ once(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1127
+ once(event: "continue", listener: () => void): this;
1128
+ once(event: "information", listener: (info: InformationEvent) => void): this;
1129
+ once(event: "response", listener: (response: IncomingMessage) => void): this;
1130
+ once(event: "socket", listener: (socket: Socket) => void): this;
1131
+ once(event: "timeout", listener: () => void): this;
1132
+ once(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1133
+ once(event: "close", listener: () => void): this;
1134
+ once(event: "drain", listener: () => void): this;
1135
+ once(event: "error", listener: (err: Error) => void): this;
1136
+ once(event: "finish", listener: () => void): this;
1137
+ once(event: "pipe", listener: (src: stream.Readable) => void): this;
1138
+ once(event: "unpipe", listener: (src: stream.Readable) => void): this;
1139
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1140
+ /**
1141
+ * @deprecated
1142
+ */
1143
+ prependListener(event: "abort", listener: () => void): this;
1144
+ prependListener(
1145
+ event: "connect",
1146
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1147
+ ): this;
1148
+ prependListener(event: "continue", listener: () => void): this;
1149
+ prependListener(event: "information", listener: (info: InformationEvent) => void): this;
1150
+ prependListener(event: "response", listener: (response: IncomingMessage) => void): this;
1151
+ prependListener(event: "socket", listener: (socket: Socket) => void): this;
1152
+ prependListener(event: "timeout", listener: () => void): this;
1153
+ prependListener(
1154
+ event: "upgrade",
1155
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1156
+ ): this;
1157
+ prependListener(event: "close", listener: () => void): this;
1158
+ prependListener(event: "drain", listener: () => void): this;
1159
+ prependListener(event: "error", listener: (err: Error) => void): this;
1160
+ prependListener(event: "finish", listener: () => void): this;
1161
+ prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1162
+ prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1163
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1164
+ /**
1165
+ * @deprecated
1166
+ */
1167
+ prependOnceListener(event: "abort", listener: () => void): this;
1168
+ prependOnceListener(
1169
+ event: "connect",
1170
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1171
+ ): this;
1172
+ prependOnceListener(event: "continue", listener: () => void): this;
1173
+ prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this;
1174
+ prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this;
1175
+ prependOnceListener(event: "socket", listener: (socket: Socket) => void): this;
1176
+ prependOnceListener(event: "timeout", listener: () => void): this;
1177
+ prependOnceListener(
1178
+ event: "upgrade",
1179
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1180
+ ): this;
1181
+ prependOnceListener(event: "close", listener: () => void): this;
1182
+ prependOnceListener(event: "drain", listener: () => void): this;
1183
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
1184
+ prependOnceListener(event: "finish", listener: () => void): this;
1185
+ prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1186
+ prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1187
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1188
+ }
1189
+ /**
1190
+ * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
1191
+ * access response
1192
+ * status, headers, and data.
1193
+ *
1194
+ * Different from its `socket` value which is a subclass of `stream.Duplex`, the `IncomingMessage` itself extends `stream.Readable` and is created separately to
1195
+ * parse and emit the incoming HTTP headers and payload, as the underlying socket
1196
+ * may be reused multiple times in case of keep-alive.
1197
+ * @since v0.1.17
1198
+ */
1199
+ class IncomingMessage extends stream.Readable {
1200
+ constructor(socket: Socket);
1201
+ /**
1202
+ * The `message.aborted` property will be `true` if the request has
1203
+ * been aborted.
1204
+ * @since v10.1.0
1205
+ * @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
1206
+ */
1207
+ aborted: boolean;
1208
+ /**
1209
+ * In case of server request, the HTTP version sent by the client. In the case of
1210
+ * client response, the HTTP version of the connected-to server.
1211
+ * Probably either `'1.1'` or `'1.0'`.
1212
+ *
1213
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1214
+ * @since v0.1.1
1215
+ */
1216
+ httpVersion: string;
1217
+ httpVersionMajor: number;
1218
+ httpVersionMinor: number;
1219
+ /**
1220
+ * The `message.complete` property will be `true` if a complete HTTP message has
1221
+ * been received and successfully parsed.
1222
+ *
1223
+ * This property is particularly useful as a means of determining if a client or
1224
+ * server fully transmitted a message before a connection was terminated:
1225
+ *
1226
+ * ```js
1227
+ * const req = http.request({
1228
+ * host: '127.0.0.1',
1229
+ * port: 8080,
1230
+ * method: 'POST',
1231
+ * }, (res) => {
1232
+ * res.resume();
1233
+ * res.on('end', () => {
1234
+ * if (!res.complete)
1235
+ * console.error(
1236
+ * 'The connection was terminated while the message was still being sent');
1237
+ * });
1238
+ * });
1239
+ * ```
1240
+ * @since v0.3.0
1241
+ */
1242
+ complete: boolean;
1243
+ /**
1244
+ * Alias for `message.socket`.
1245
+ * @since v0.1.90
1246
+ * @deprecated Since v16.0.0 - Use `socket`.
1247
+ */
1248
+ connection: Socket;
1249
+ /**
1250
+ * The `net.Socket` object associated with the connection.
1251
+ *
1252
+ * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the
1253
+ * client's authentication details.
1254
+ *
1255
+ * This property is guaranteed to be an instance of the `net.Socket` class,
1256
+ * a subclass of `stream.Duplex`, unless the user specified a socket
1257
+ * type other than `net.Socket` or internally nulled.
1258
+ * @since v0.3.0
1259
+ */
1260
+ socket: Socket;
1261
+ /**
1262
+ * The request/response headers object.
1263
+ *
1264
+ * Key-value pairs of header names and values. Header names are lower-cased.
1265
+ *
1266
+ * ```js
1267
+ * // Prints something like:
1268
+ * //
1269
+ * // { 'user-agent': 'curl/7.22.0',
1270
+ * // host: '127.0.0.1:8000',
1271
+ * // accept: '*' }
1272
+ * console.log(request.headers);
1273
+ * ```
1274
+ *
1275
+ * Duplicates in raw headers are handled in the following ways, depending on the
1276
+ * header name:
1277
+ *
1278
+ * * Duplicates of `age`, `authorization`, `content-length`, `content-type`, `etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
1279
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`, or `user-agent` are discarded.
1280
+ * To allow duplicate values of the headers listed above to be joined,
1281
+ * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
1282
+ * information.
1283
+ * * `set-cookie` is always an array. Duplicates are added to the array.
1284
+ * * For duplicate `cookie` headers, the values are joined together with `; `.
1285
+ * * For all other headers, the values are joined together with `, `.
1286
+ * @since v0.1.5
1287
+ */
1288
+ headers: IncomingHttpHeaders;
1289
+ /**
1290
+ * Similar to `message.headers`, but there is no join logic and the values are
1291
+ * always arrays of strings, even for headers received just once.
1292
+ *
1293
+ * ```js
1294
+ * // Prints something like:
1295
+ * //
1296
+ * // { 'user-agent': ['curl/7.22.0'],
1297
+ * // host: ['127.0.0.1:8000'],
1298
+ * // accept: ['*'] }
1299
+ * console.log(request.headersDistinct);
1300
+ * ```
1301
+ * @since v18.3.0, v16.17.0
1302
+ */
1303
+ headersDistinct: NodeJS.Dict<string[]>;
1304
+ /**
1305
+ * The raw request/response headers list exactly as they were received.
1306
+ *
1307
+ * The keys and values are in the same list. It is _not_ a
1308
+ * list of tuples. So, the even-numbered offsets are key values, and the
1309
+ * odd-numbered offsets are the associated values.
1310
+ *
1311
+ * Header names are not lowercased, and duplicates are not merged.
1312
+ *
1313
+ * ```js
1314
+ * // Prints something like:
1315
+ * //
1316
+ * // [ 'user-agent',
1317
+ * // 'this is invalid because there can be only one',
1318
+ * // 'User-Agent',
1319
+ * // 'curl/7.22.0',
1320
+ * // 'Host',
1321
+ * // '127.0.0.1:8000',
1322
+ * // 'ACCEPT',
1323
+ * // '*' ]
1324
+ * console.log(request.rawHeaders);
1325
+ * ```
1326
+ * @since v0.11.6
1327
+ */
1328
+ rawHeaders: string[];
1329
+ /**
1330
+ * The request/response trailers object. Only populated at the `'end'` event.
1331
+ * @since v0.3.0
1332
+ */
1333
+ trailers: NodeJS.Dict<string>;
1334
+ /**
1335
+ * Similar to `message.trailers`, but there is no join logic and the values are
1336
+ * always arrays of strings, even for headers received just once.
1337
+ * Only populated at the `'end'` event.
1338
+ * @since v18.3.0, v16.17.0
1339
+ */
1340
+ trailersDistinct: NodeJS.Dict<string[]>;
1341
+ /**
1342
+ * The raw request/response trailer keys and values exactly as they were
1343
+ * received. Only populated at the `'end'` event.
1344
+ * @since v0.11.6
1345
+ */
1346
+ rawTrailers: string[];
1347
+ /**
1348
+ * Calls `message.socket.setTimeout(msecs, callback)`.
1349
+ * @since v0.5.9
1350
+ */
1351
+ setTimeout(msecs: number, callback?: () => void): this;
1352
+ /**
1353
+ * **Only valid for request obtained from {@link Server}.**
1354
+ *
1355
+ * The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`.
1356
+ * @since v0.1.1
1357
+ */
1358
+ method?: string | undefined;
1359
+ /**
1360
+ * **Only valid for request obtained from {@link Server}.**
1361
+ *
1362
+ * Request URL string. This contains only the URL that is present in the actual
1363
+ * HTTP request. Take the following request:
1364
+ *
1365
+ * ```http
1366
+ * GET /status?name=ryan HTTP/1.1
1367
+ * Accept: text/plain
1368
+ * ```
1369
+ *
1370
+ * To parse the URL into its parts:
1371
+ *
1372
+ * ```js
1373
+ * new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
1374
+ * ```
1375
+ *
1376
+ * When `request.url` is `'/status?name=ryan'` and `process.env.HOST` is undefined:
1377
+ *
1378
+ * ```console
1379
+ * $ node
1380
+ * > new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
1381
+ * URL {
1382
+ * href: 'http://localhost/status?name=ryan',
1383
+ * origin: 'http://localhost',
1384
+ * protocol: 'http:',
1385
+ * username: '',
1386
+ * password: '',
1387
+ * host: 'localhost',
1388
+ * hostname: 'localhost',
1389
+ * port: '',
1390
+ * pathname: '/status',
1391
+ * search: '?name=ryan',
1392
+ * searchParams: URLSearchParams { 'name' => 'ryan' },
1393
+ * hash: ''
1394
+ * }
1395
+ * ```
1396
+ *
1397
+ * Ensure that you set `process.env.HOST` to the server's host name, or consider replacing this part entirely. If using `req.headers.host`, ensure proper
1398
+ * validation is used, as clients may specify a custom `Host` header.
1399
+ * @since v0.1.90
1400
+ */
1401
+ url?: string | undefined;
1402
+ /**
1403
+ * **Only valid for response obtained from {@link ClientRequest}.**
1404
+ *
1405
+ * The 3-digit HTTP response status code. E.G. `404`.
1406
+ * @since v0.1.1
1407
+ */
1408
+ statusCode?: number | undefined;
1409
+ /**
1410
+ * **Only valid for response obtained from {@link ClientRequest}.**
1411
+ *
1412
+ * The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`.
1413
+ * @since v0.11.10
1414
+ */
1415
+ statusMessage?: string | undefined;
1416
+ /**
1417
+ * Calls `destroy()` on the socket that received the `IncomingMessage`. If `error` is provided, an `'error'` event is emitted on the socket and `error` is passed
1418
+ * as an argument to any listeners on the event.
1419
+ * @since v0.3.0
1420
+ */
1421
+ destroy(error?: Error): this;
1422
+ }
1423
+ interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1424
+ /**
1425
+ * Keep sockets around in a pool to be used by other requests in the future. Default = false
1426
+ */
1427
+ keepAlive?: boolean | undefined;
1428
+ /**
1429
+ * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
1430
+ * Only relevant if keepAlive is set to true.
1431
+ */
1432
+ keepAliveMsecs?: number | undefined;
1433
+ /**
1434
+ * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1435
+ */
1436
+ maxSockets?: number | undefined;
1437
+ /**
1438
+ * Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
1439
+ */
1440
+ maxTotalSockets?: number | undefined;
1441
+ /**
1442
+ * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
1443
+ */
1444
+ maxFreeSockets?: number | undefined;
1445
+ /**
1446
+ * Socket timeout in milliseconds. This will set the timeout after the socket is connected.
1447
+ */
1448
+ timeout?: number | undefined;
1449
+ /**
1450
+ * Scheduling strategy to apply when picking the next free socket to use.
1451
+ * @default `lifo`
1452
+ */
1453
+ scheduling?: "fifo" | "lifo" | undefined;
1454
+ }
1455
+ /**
1456
+ * An `Agent` is responsible for managing connection persistence
1457
+ * and reuse for HTTP clients. It maintains a queue of pending requests
1458
+ * for a given host and port, reusing a single socket connection for each
1459
+ * until the queue is empty, at which time the socket is either destroyed
1460
+ * or put into a pool where it is kept to be used again for requests to the
1461
+ * same host and port. Whether it is destroyed or pooled depends on the `keepAlive` `option`.
1462
+ *
1463
+ * Pooled connections have TCP Keep-Alive enabled for them, but servers may
1464
+ * still close idle connections, in which case they will be removed from the
1465
+ * pool and a new connection will be made when a new HTTP request is made for
1466
+ * that host and port. Servers may also refuse to allow multiple requests
1467
+ * over the same connection, in which case the connection will have to be
1468
+ * remade for every request and cannot be pooled. The `Agent` will still make
1469
+ * the requests to that server, but each one will occur over a new connection.
1470
+ *
1471
+ * When a connection is closed by the client or the server, it is removed
1472
+ * from the pool. Any unused sockets in the pool will be unrefed so as not
1473
+ * to keep the Node.js process running when there are no outstanding requests.
1474
+ * (see `socket.unref()`).
1475
+ *
1476
+ * It is good practice, to `destroy()` an `Agent` instance when it is no
1477
+ * longer in use, because unused sockets consume OS resources.
1478
+ *
1479
+ * Sockets are removed from an agent when the socket emits either
1480
+ * a `'close'` event or an `'agentRemove'` event. When intending to keep one
1481
+ * HTTP request open for a long time without keeping it in the agent, something
1482
+ * like the following may be done:
1483
+ *
1484
+ * ```js
1485
+ * http.get(options, (res) => {
1486
+ * // Do stuff
1487
+ * }).on('socket', (socket) => {
1488
+ * socket.emit('agentRemove');
1489
+ * });
1490
+ * ```
1491
+ *
1492
+ * An agent may also be used for an individual request. By providing `{agent: false}` as an option to the `http.get()` or `http.request()` functions, a one-time use `Agent` with default options
1493
+ * will be used
1494
+ * for the client connection.
1495
+ *
1496
+ * `agent:false`:
1497
+ *
1498
+ * ```js
1499
+ * http.get({
1500
+ * hostname: 'localhost',
1501
+ * port: 80,
1502
+ * path: '/',
1503
+ * agent: false, // Create a new agent just for this one request
1504
+ * }, (res) => {
1505
+ * // Do stuff with response
1506
+ * });
1507
+ * ```
1508
+ *
1509
+ * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v24.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
1510
+ *
1511
+ * To configure any of them, a custom {@link Agent} instance must be created.
1512
+ *
1513
+ * ```js
1514
+ * import http from 'node:http';
1515
+ * const keepAliveAgent = new http.Agent({ keepAlive: true });
1516
+ * options.agent = keepAliveAgent;
1517
+ * http.request(options, onResponseCallback)
1518
+ * ```
1519
+ * @since v0.3.4
1520
+ */
1521
+ class Agent extends EventEmitter {
1522
+ /**
1523
+ * By default set to 256. For agents with `keepAlive` enabled, this
1524
+ * sets the maximum number of sockets that will be left open in the free
1525
+ * state.
1526
+ * @since v0.11.7
1527
+ */
1528
+ maxFreeSockets: number;
1529
+ /**
1530
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1531
+ * can have open per origin. Origin is the returned value of `agent.getName()`.
1532
+ * @since v0.3.6
1533
+ */
1534
+ maxSockets: number;
1535
+ /**
1536
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1537
+ * can have open. Unlike `maxSockets`, this parameter applies across all origins.
1538
+ * @since v14.5.0, v12.19.0
1539
+ */
1540
+ maxTotalSockets: number;
1541
+ /**
1542
+ * An object which contains arrays of sockets currently awaiting use by
1543
+ * the agent when `keepAlive` is enabled. Do not modify.
1544
+ *
1545
+ * Sockets in the `freeSockets` list will be automatically destroyed and
1546
+ * removed from the array on `'timeout'`.
1547
+ * @since v0.11.4
1548
+ */
1549
+ readonly freeSockets: NodeJS.ReadOnlyDict<Socket[]>;
1550
+ /**
1551
+ * An object which contains arrays of sockets currently in use by the
1552
+ * agent. Do not modify.
1553
+ * @since v0.3.6
1554
+ */
1555
+ readonly sockets: NodeJS.ReadOnlyDict<Socket[]>;
1556
+ /**
1557
+ * An object which contains queues of requests that have not yet been assigned to
1558
+ * sockets. Do not modify.
1559
+ * @since v0.5.9
1560
+ */
1561
+ readonly requests: NodeJS.ReadOnlyDict<IncomingMessage[]>;
1562
+ constructor(opts?: AgentOptions);
1563
+ /**
1564
+ * Destroy any sockets that are currently in use by the agent.
1565
+ *
1566
+ * It is usually not necessary to do this. However, if using an
1567
+ * agent with `keepAlive` enabled, then it is best to explicitly shut down
1568
+ * the agent when it is no longer needed. Otherwise,
1569
+ * sockets might stay open for quite a long time before the server
1570
+ * terminates them.
1571
+ * @since v0.11.4
1572
+ */
1573
+ destroy(): void;
1574
+ /**
1575
+ * Produces a socket/stream to be used for HTTP requests.
1576
+ *
1577
+ * By default, this function is the same as `net.createConnection()`. However,
1578
+ * custom agents may override this method in case greater flexibility is desired.
1579
+ *
1580
+ * A socket/stream can be supplied in one of two ways: by returning the
1581
+ * socket/stream from this function, or by passing the socket/stream to `callback`.
1582
+ *
1583
+ * This method is guaranteed to return an instance of the `net.Socket` class,
1584
+ * a subclass of `stream.Duplex`, unless the user specifies a socket
1585
+ * type other than `net.Socket`.
1586
+ *
1587
+ * `callback` has a signature of `(err, stream)`.
1588
+ * @since v0.11.4
1589
+ * @param options Options containing connection details. Check `createConnection` for the format of the options
1590
+ * @param callback Callback function that receives the created socket
1591
+ */
1592
+ createConnection(
1593
+ options: ClientRequestArgs,
1594
+ callback?: (err: Error | null, stream: stream.Duplex) => void,
1595
+ ): stream.Duplex;
1596
+ /**
1597
+ * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
1598
+ *
1599
+ * ```js
1600
+ * socket.setKeepAlive(true, this.keepAliveMsecs);
1601
+ * socket.unref();
1602
+ * return true;
1603
+ * ```
1604
+ *
1605
+ * This method can be overridden by a particular `Agent` subclass. If this
1606
+ * method returns a falsy value, the socket will be destroyed instead of persisting
1607
+ * it for use with the next request.
1608
+ *
1609
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1610
+ * @since v8.1.0
1611
+ */
1612
+ keepSocketAlive(socket: stream.Duplex): void;
1613
+ /**
1614
+ * Called when `socket` is attached to `request` after being persisted because of
1615
+ * the keep-alive options. Default behavior is to:
1616
+ *
1617
+ * ```js
1618
+ * socket.ref();
1619
+ * ```
1620
+ *
1621
+ * This method can be overridden by a particular `Agent` subclass.
1622
+ *
1623
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1624
+ * @since v8.1.0
1625
+ */
1626
+ reuseSocket(socket: stream.Duplex, request: ClientRequest): void;
1627
+ /**
1628
+ * Get a unique name for a set of request options, to determine whether a
1629
+ * connection can be reused. For an HTTP agent, this returns`host:port:localAddress` or `host:port:localAddress:family`. For an HTTPS agent,
1630
+ * the name includes the CA, cert, ciphers, and other HTTPS/TLS-specific options
1631
+ * that determine socket reusability.
1632
+ * @since v0.11.4
1633
+ * @param options A set of options providing information for name generation
1634
+ */
1635
+ getName(options?: ClientRequestArgs): string;
1636
+ }
1637
+ const METHODS: string[];
1638
+ const STATUS_CODES: {
1639
+ [errorCode: number]: string | undefined;
1640
+ [errorCode: string]: string | undefined;
1641
+ };
1642
+ /**
1643
+ * Returns a new instance of {@link Server}.
1644
+ *
1645
+ * The `requestListener` is a function which is automatically
1646
+ * added to the `'request'` event.
1647
+ *
1648
+ * ```js
1649
+ * import http from 'node:http';
1650
+ *
1651
+ * // Create a local server to receive data from
1652
+ * const server = http.createServer((req, res) => {
1653
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1654
+ * res.end(JSON.stringify({
1655
+ * data: 'Hello World!',
1656
+ * }));
1657
+ * });
1658
+ *
1659
+ * server.listen(8000);
1660
+ * ```
1661
+ *
1662
+ * ```js
1663
+ * import http from 'node:http';
1664
+ *
1665
+ * // Create a local server to receive data from
1666
+ * const server = http.createServer();
1667
+ *
1668
+ * // Listen to the request event
1669
+ * server.on('request', (request, res) => {
1670
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1671
+ * res.end(JSON.stringify({
1672
+ * data: 'Hello World!',
1673
+ * }));
1674
+ * });
1675
+ *
1676
+ * server.listen(8000);
1677
+ * ```
1678
+ * @since v0.1.13
1679
+ */
1680
+ function createServer<
1681
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1682
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1683
+ >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1684
+ function createServer<
1685
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1686
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1687
+ >(
1688
+ options: ServerOptions<Request, Response>,
1689
+ requestListener?: RequestListener<Request, Response>,
1690
+ ): Server<Request, Response>;
1691
+ // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
1692
+ // create interface RequestOptions would make the naming more clear to developers
1693
+ interface RequestOptions extends ClientRequestArgs {}
1694
+ /**
1695
+ * `options` in `socket.connect()` are also supported.
1696
+ *
1697
+ * Node.js maintains several connections per server to make HTTP requests.
1698
+ * This function allows one to transparently issue requests.
1699
+ *
1700
+ * `url` can be a string or a `URL` object. If `url` is a
1701
+ * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
1702
+ *
1703
+ * If both `url` and `options` are specified, the objects are merged, with the `options` properties taking precedence.
1704
+ *
1705
+ * The optional `callback` parameter will be added as a one-time listener for
1706
+ * the `'response'` event.
1707
+ *
1708
+ * `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to
1709
+ * upload a file with a POST request, then write to the `ClientRequest` object.
1710
+ *
1711
+ * ```js
1712
+ * import http from 'node:http';
1713
+ * import { Buffer } from 'node:buffer';
1714
+ *
1715
+ * const postData = JSON.stringify({
1716
+ * 'msg': 'Hello World!',
1717
+ * });
1718
+ *
1719
+ * const options = {
1720
+ * hostname: 'www.google.com',
1721
+ * port: 80,
1722
+ * path: '/upload',
1723
+ * method: 'POST',
1724
+ * headers: {
1725
+ * 'Content-Type': 'application/json',
1726
+ * 'Content-Length': Buffer.byteLength(postData),
1727
+ * },
1728
+ * };
1729
+ *
1730
+ * const req = http.request(options, (res) => {
1731
+ * console.log(`STATUS: ${res.statusCode}`);
1732
+ * console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
1733
+ * res.setEncoding('utf8');
1734
+ * res.on('data', (chunk) => {
1735
+ * console.log(`BODY: ${chunk}`);
1736
+ * });
1737
+ * res.on('end', () => {
1738
+ * console.log('No more data in response.');
1739
+ * });
1740
+ * });
1741
+ *
1742
+ * req.on('error', (e) => {
1743
+ * console.error(`problem with request: ${e.message}`);
1744
+ * });
1745
+ *
1746
+ * // Write data to request body
1747
+ * req.write(postData);
1748
+ * req.end();
1749
+ * ```
1750
+ *
1751
+ * In the example `req.end()` was called. With `http.request()` one
1752
+ * must always call `req.end()` to signify the end of the request -
1753
+ * even if there is no data being written to the request body.
1754
+ *
1755
+ * If any error is encountered during the request (be that with DNS resolution,
1756
+ * TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted
1757
+ * on the returned request object. As with all `'error'` events, if no listeners
1758
+ * are registered the error will be thrown.
1759
+ *
1760
+ * There are a few special headers that should be noted.
1761
+ *
1762
+ * * Sending a 'Connection: keep-alive' will notify Node.js that the connection to
1763
+ * the server should be persisted until the next request.
1764
+ * * Sending a 'Content-Length' header will disable the default chunked encoding.
1765
+ * * Sending an 'Expect' header will immediately send the request headers.
1766
+ * Usually, when sending 'Expect: 100-continue', both a timeout and a listener
1767
+ * for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more
1768
+ * information.
1769
+ * * Sending an Authorization header will override using the `auth` option
1770
+ * to compute basic authentication.
1771
+ *
1772
+ * Example using a `URL` as `options`:
1773
+ *
1774
+ * ```js
1775
+ * const options = new URL('http://abc:xyz@example.com');
1776
+ *
1777
+ * const req = http.request(options, (res) => {
1778
+ * // ...
1779
+ * });
1780
+ * ```
1781
+ *
1782
+ * In a successful request, the following events will be emitted in the following
1783
+ * order:
1784
+ *
1785
+ * * `'socket'`
1786
+ * * `'response'`
1787
+ * * `'data'` any number of times, on the `res` object
1788
+ * (`'data'` will not be emitted at all if the response body is empty, for
1789
+ * instance, in most redirects)
1790
+ * * `'end'` on the `res` object
1791
+ * * `'close'`
1792
+ *
1793
+ * In the case of a connection error, the following events will be emitted:
1794
+ *
1795
+ * * `'socket'`
1796
+ * * `'error'`
1797
+ * * `'close'`
1798
+ *
1799
+ * In the case of a premature connection close before the response is received,
1800
+ * the following events will be emitted in the following order:
1801
+ *
1802
+ * * `'socket'`
1803
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
1804
+ * * `'close'`
1805
+ *
1806
+ * In the case of a premature connection close after the response is received,
1807
+ * the following events will be emitted in the following order:
1808
+ *
1809
+ * * `'socket'`
1810
+ * * `'response'`
1811
+ * * `'data'` any number of times, on the `res` object
1812
+ * * (connection closed here)
1813
+ * * `'aborted'` on the `res` object
1814
+ * * `'close'`
1815
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`
1816
+ * * `'close'` on the `res` object
1817
+ *
1818
+ * If `req.destroy()` is called before a socket is assigned, the following
1819
+ * events will be emitted in the following order:
1820
+ *
1821
+ * * (`req.destroy()` called here)
1822
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1823
+ * * `'close'`
1824
+ *
1825
+ * If `req.destroy()` is called before the connection succeeds, the following
1826
+ * events will be emitted in the following order:
1827
+ *
1828
+ * * `'socket'`
1829
+ * * (`req.destroy()` called here)
1830
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1831
+ * * `'close'`
1832
+ *
1833
+ * If `req.destroy()` is called after the response is received, the following
1834
+ * events will be emitted in the following order:
1835
+ *
1836
+ * * `'socket'`
1837
+ * * `'response'`
1838
+ * * `'data'` any number of times, on the `res` object
1839
+ * * (`req.destroy()` called here)
1840
+ * * `'aborted'` on the `res` object
1841
+ * * `'close'`
1842
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1843
+ * * `'close'` on the `res` object
1844
+ *
1845
+ * If `req.abort()` is called before a socket is assigned, the following
1846
+ * events will be emitted in the following order:
1847
+ *
1848
+ * * (`req.abort()` called here)
1849
+ * * `'abort'`
1850
+ * * `'close'`
1851
+ *
1852
+ * If `req.abort()` is called before the connection succeeds, the following
1853
+ * events will be emitted in the following order:
1854
+ *
1855
+ * * `'socket'`
1856
+ * * (`req.abort()` called here)
1857
+ * * `'abort'`
1858
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
1859
+ * * `'close'`
1860
+ *
1861
+ * If `req.abort()` is called after the response is received, the following
1862
+ * events will be emitted in the following order:
1863
+ *
1864
+ * * `'socket'`
1865
+ * * `'response'`
1866
+ * * `'data'` any number of times, on the `res` object
1867
+ * * (`req.abort()` called here)
1868
+ * * `'abort'`
1869
+ * * `'aborted'` on the `res` object
1870
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`.
1871
+ * * `'close'`
1872
+ * * `'close'` on the `res` object
1873
+ *
1874
+ * Setting the `timeout` option or using the `setTimeout()` function will
1875
+ * not abort the request or do anything besides add a `'timeout'` event.
1876
+ *
1877
+ * Passing an `AbortSignal` and then calling `abort()` on the corresponding `AbortController` will behave the same way as calling `.destroy()` on the
1878
+ * request. Specifically, the `'error'` event will be emitted with an error with
1879
+ * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'` and the `cause`, if one was provided.
1880
+ * @since v0.3.6
1881
+ */
1882
+ function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1883
+ function request(
1884
+ url: string | URL,
1885
+ options: RequestOptions,
1886
+ callback?: (res: IncomingMessage) => void,
1887
+ ): ClientRequest;
1888
+ /**
1889
+ * Since most requests are GET requests without bodies, Node.js provides this
1890
+ * convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()` automatically. The callback must take care to
1891
+ * consume the response
1892
+ * data for reasons stated in {@link ClientRequest} section.
1893
+ *
1894
+ * The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}.
1895
+ *
1896
+ * JSON fetching example:
1897
+ *
1898
+ * ```js
1899
+ * http.get('http://localhost:8000/', (res) => {
1900
+ * const { statusCode } = res;
1901
+ * const contentType = res.headers['content-type'];
1902
+ *
1903
+ * let error;
1904
+ * // Any 2xx status code signals a successful response but
1905
+ * // here we're only checking for 200.
1906
+ * if (statusCode !== 200) {
1907
+ * error = new Error('Request Failed.\n' +
1908
+ * `Status Code: ${statusCode}`);
1909
+ * } else if (!/^application\/json/.test(contentType)) {
1910
+ * error = new Error('Invalid content-type.\n' +
1911
+ * `Expected application/json but received ${contentType}`);
1912
+ * }
1913
+ * if (error) {
1914
+ * console.error(error.message);
1915
+ * // Consume response data to free up memory
1916
+ * res.resume();
1917
+ * return;
1918
+ * }
1919
+ *
1920
+ * res.setEncoding('utf8');
1921
+ * let rawData = '';
1922
+ * res.on('data', (chunk) => { rawData += chunk; });
1923
+ * res.on('end', () => {
1924
+ * try {
1925
+ * const parsedData = JSON.parse(rawData);
1926
+ * console.log(parsedData);
1927
+ * } catch (e) {
1928
+ * console.error(e.message);
1929
+ * }
1930
+ * });
1931
+ * }).on('error', (e) => {
1932
+ * console.error(`Got error: ${e.message}`);
1933
+ * });
1934
+ *
1935
+ * // Create a local server to receive data from
1936
+ * const server = http.createServer((req, res) => {
1937
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1938
+ * res.end(JSON.stringify({
1939
+ * data: 'Hello World!',
1940
+ * }));
1941
+ * });
1942
+ *
1943
+ * server.listen(8000);
1944
+ * ```
1945
+ * @since v0.3.6
1946
+ * @param options Accepts the same `options` as {@link request}, with the method set to GET by default.
1947
+ */
1948
+ function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1949
+ function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1950
+ /**
1951
+ * Performs the low-level validations on the provided `name` that are done when `res.setHeader(name, value)` is called.
1952
+ *
1953
+ * Passing illegal value as `name` will result in a `TypeError` being thrown,
1954
+ * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1955
+ *
1956
+ * It is not necessary to use this method before passing headers to an HTTP request
1957
+ * or response. The HTTP module will automatically validate such headers.
1958
+ *
1959
+ * Example:
1960
+ *
1961
+ * ```js
1962
+ * import { validateHeaderName } from 'node:http';
1963
+ *
1964
+ * try {
1965
+ * validateHeaderName('');
1966
+ * } catch (err) {
1967
+ * console.error(err instanceof TypeError); // --> true
1968
+ * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
1969
+ * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
1970
+ * }
1971
+ * ```
1972
+ * @since v14.3.0
1973
+ * @param [label='Header name'] Label for error message.
1974
+ */
1975
+ function validateHeaderName(name: string): void;
1976
+ /**
1977
+ * Performs the low-level validations on the provided `value` that are done when `res.setHeader(name, value)` is called.
1978
+ *
1979
+ * Passing illegal value as `value` will result in a `TypeError` being thrown.
1980
+ *
1981
+ * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1982
+ * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1983
+ *
1984
+ * It is not necessary to use this method before passing headers to an HTTP request
1985
+ * or response. The HTTP module will automatically validate such headers.
1986
+ *
1987
+ * Examples:
1988
+ *
1989
+ * ```js
1990
+ * import { validateHeaderValue } from 'node:http';
1991
+ *
1992
+ * try {
1993
+ * validateHeaderValue('x-my-header', undefined);
1994
+ * } catch (err) {
1995
+ * console.error(err instanceof TypeError); // --> true
1996
+ * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
1997
+ * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
1998
+ * }
1999
+ *
2000
+ * try {
2001
+ * validateHeaderValue('x-my-header', 'oʊmɪɡə');
2002
+ * } catch (err) {
2003
+ * console.error(err instanceof TypeError); // --> true
2004
+ * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
2005
+ * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
2006
+ * }
2007
+ * ```
2008
+ * @since v14.3.0
2009
+ * @param name Header name
2010
+ * @param value Header value
2011
+ */
2012
+ function validateHeaderValue(name: string, value: string): void;
2013
+ /**
2014
+ * Set the maximum number of idle HTTP parsers.
2015
+ * @since v18.8.0, v16.18.0
2016
+ * @param [max=1000]
2017
+ */
2018
+ function setMaxIdleHTTPParsers(max: number): void;
2019
+ /**
2020
+ * Global instance of `Agent` which is used as the default for all HTTP client
2021
+ * requests. Diverges from a default `Agent` configuration by having `keepAlive`
2022
+ * enabled and a `timeout` of 5 seconds.
2023
+ * @since v0.5.9
2024
+ */
2025
+ let globalAgent: Agent;
2026
+ /**
2027
+ * Read-only property specifying the maximum allowed size of HTTP headers in bytes.
2028
+ * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
2029
+ */
2030
+ const maxHeaderSize: number;
2031
+ /**
2032
+ * A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
2033
+ * @since v22.5.0
2034
+ */
2035
+ const WebSocket: import('./undici-types').WebSocket;
2036
+ /**
2037
+ * @since v22.5.0
2038
+ */
2039
+ const CloseEvent: import('./undici-types').CloseEvent;
2040
+ /**
2041
+ * @since v22.5.0
2042
+ */
2043
+ const MessageEvent: import('./undici-types').MessageEvent;
2044
+ }