@rio-cloud/cdk-v2-constructs 8.2.0 → 8.2.1

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 (179) hide show
  1. package/.jsii +2 -2
  2. package/node_modules/@types/node/README.md +3 -3
  3. package/node_modules/@types/node/assert/strict.d.ts +105 -2
  4. package/node_modules/@types/node/assert.d.ts +211 -92
  5. package/node_modules/@types/node/async_hooks.d.ts +103 -19
  6. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  7. package/node_modules/@types/node/buffer.d.ts +88 -516
  8. package/node_modules/@types/node/child_process.d.ts +167 -231
  9. package/node_modules/@types/node/cluster.d.ts +172 -26
  10. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  11. package/node_modules/@types/node/console.d.ts +66 -28
  12. package/node_modules/@types/node/constants.d.ts +14 -12
  13. package/node_modules/@types/node/crypto.d.ts +1458 -497
  14. package/node_modules/@types/node/dgram.d.ts +44 -30
  15. package/node_modules/@types/node/diagnostics_channel.d.ts +389 -4
  16. package/node_modules/@types/node/dns/promises.d.ts +120 -42
  17. package/node_modules/@types/node/dns.d.ts +209 -95
  18. package/node_modules/@types/node/domain.d.ts +14 -18
  19. package/node_modules/@types/node/events.d.ts +245 -113
  20. package/node_modules/@types/node/fs/promises.d.ts +194 -96
  21. package/node_modules/@types/node/fs.d.ts +695 -270
  22. package/node_modules/@types/node/globals.d.ts +97 -308
  23. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  24. package/node_modules/@types/node/http.d.ts +363 -97
  25. package/node_modules/@types/node/http2.d.ts +684 -231
  26. package/node_modules/@types/node/https.d.ts +122 -87
  27. package/node_modules/@types/node/index.d.ts +24 -11
  28. package/node_modules/@types/node/inspector.d.ts +220 -2690
  29. package/node_modules/@types/node/inspector.generated.d.ts +4239 -0
  30. package/node_modules/@types/node/module.d.ts +705 -149
  31. package/node_modules/@types/node/net.d.ts +178 -54
  32. package/node_modules/@types/node/os.d.ts +47 -17
  33. package/node_modules/@types/node/package.json +22 -97
  34. package/node_modules/@types/node/path.d.ts +12 -3
  35. package/node_modules/@types/node/perf_hooks.d.ts +500 -97
  36. package/node_modules/@types/node/process.d.ts +657 -87
  37. package/node_modules/@types/node/punycode.d.ts +5 -5
  38. package/node_modules/@types/node/querystring.d.ts +24 -13
  39. package/node_modules/@types/node/readline/promises.d.ts +25 -14
  40. package/node_modules/@types/node/readline.d.ts +102 -41
  41. package/node_modules/@types/node/repl.d.ts +38 -30
  42. package/node_modules/@types/node/sea.d.ts +162 -0
  43. package/node_modules/@types/node/sqlite.d.ts +1040 -0
  44. package/node_modules/@types/node/stream/consumers.d.ts +33 -7
  45. package/node_modules/@types/node/stream/promises.d.ts +8 -1
  46. package/node_modules/@types/node/stream/web.d.ts +251 -28
  47. package/node_modules/@types/node/stream.d.ts +1060 -1055
  48. package/node_modules/@types/node/string_decoder.d.ts +8 -8
  49. package/node_modules/@types/node/test.d.ts +2133 -1166
  50. package/node_modules/@types/node/timers/promises.d.ts +31 -16
  51. package/node_modules/@types/node/timers.d.ts +159 -114
  52. package/node_modules/@types/node/tls.d.ts +232 -163
  53. package/node_modules/@types/node/trace_events.d.ts +43 -28
  54. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  55. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  56. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  57. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  58. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  59. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  60. package/node_modules/@types/node/tty.d.ts +9 -9
  61. package/node_modules/@types/node/url.d.ts +236 -84
  62. package/node_modules/@types/node/util.d.ts +562 -412
  63. package/node_modules/@types/node/v8.d.ts +368 -21
  64. package/node_modules/@types/node/vm.d.ts +443 -149
  65. package/node_modules/@types/node/wasi.d.ts +62 -18
  66. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  67. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  68. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  69. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  70. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  71. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  72. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  73. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  74. package/node_modules/@types/node/worker_threads.d.ts +310 -107
  75. package/node_modules/@types/node/zlib.d.ts +301 -73
  76. package/node_modules/undici-types/LICENSE +21 -0
  77. package/node_modules/undici-types/agent.d.ts +13 -12
  78. package/node_modules/undici-types/api.d.ts +26 -26
  79. package/node_modules/undici-types/balanced-pool.d.ts +19 -7
  80. package/node_modules/undici-types/cache-interceptor.d.ts +173 -0
  81. package/node_modules/undici-types/client-stats.d.ts +15 -0
  82. package/node_modules/undici-types/client.d.ts +26 -15
  83. package/node_modules/undici-types/connector.d.ts +2 -2
  84. package/node_modules/undici-types/cookies.d.ts +2 -0
  85. package/node_modules/undici-types/diagnostics-channel.d.ts +19 -12
  86. package/node_modules/undici-types/dispatcher.d.ts +148 -113
  87. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  88. package/node_modules/undici-types/errors.d.ts +79 -46
  89. package/node_modules/undici-types/eventsource.d.ts +66 -0
  90. package/node_modules/undici-types/fetch.d.ts +41 -39
  91. package/node_modules/undici-types/formdata.d.ts +8 -8
  92. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  93. package/node_modules/undici-types/global-origin.d.ts +5 -5
  94. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  95. package/node_modules/undici-types/handlers.d.ts +11 -5
  96. package/node_modules/undici-types/header.d.ts +157 -1
  97. package/node_modules/undici-types/index.d.ts +68 -43
  98. package/node_modules/undici-types/interceptors.d.ts +71 -3
  99. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  100. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  101. package/node_modules/undici-types/mock-client.d.ts +6 -4
  102. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  103. package/node_modules/undici-types/mock-interceptor.d.ts +24 -23
  104. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  105. package/node_modules/undici-types/package.json +1 -1
  106. package/node_modules/undici-types/patch.d.ts +0 -42
  107. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  108. package/node_modules/undici-types/pool.d.ts +21 -8
  109. package/node_modules/undici-types/proxy-agent.d.ts +5 -6
  110. package/node_modules/undici-types/readable.d.ts +24 -17
  111. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  112. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  113. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  114. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  115. package/node_modules/undici-types/util.d.ts +18 -0
  116. package/node_modules/undici-types/utility.d.ts +7 -0
  117. package/node_modules/undici-types/webidl.d.ts +157 -36
  118. package/node_modules/undici-types/websocket.d.ts +67 -12
  119. package/package.json +9 -60
  120. package/version.json +1 -1
  121. package/node_modules/@types/node/dom-events.d.ts +0 -122
  122. package/node_modules/@types/node/globals.global.d.ts +0 -1
  123. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  124. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  125. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  126. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2362
  127. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  128. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  129. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  130. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  131. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4455
  132. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -586
  133. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -191
  134. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  135. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  136. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  137. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  138. package/node_modules/@types/node/ts4.8/events.d.ts +0 -796
  139. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1232
  140. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4289
  141. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -381
  142. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  143. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1888
  144. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  145. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  146. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  147. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  148. package/node_modules/@types/node/ts4.8/module.d.ts +0 -287
  149. package/node_modules/@types/node/ts4.8/net.d.ts +0 -949
  150. package/node_modules/@types/node/ts4.8/os.d.ts +0 -477
  151. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  152. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -639
  153. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1532
  154. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  155. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  156. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  157. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  158. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  159. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  160. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  161. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -350
  162. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  163. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  164. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1382
  165. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  166. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  167. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  168. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  169. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  170. package/node_modules/@types/node/ts4.8/url.d.ts +0 -927
  171. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2186
  172. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -635
  173. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -901
  174. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  175. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  176. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  177. package/node_modules/argparse/CHANGELOG.md +0 -216
  178. package/node_modules/undici-types/file.d.ts +0 -39
  179. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -1,5 +1,5 @@
1
1
  /**
2
- * To use the HTTP server and client one must `require('node:http')`.
2
+ * To use the HTTP server and client one must import the `node:http` module.
3
3
  *
4
4
  * The HTTP interfaces in Node.js are designed to support many features
5
5
  * of the protocol which have been traditionally difficult to use.
@@ -9,12 +9,12 @@
9
9
  *
10
10
  * HTTP message headers are represented by an object like this:
11
11
  *
12
- * ```js
13
- * { 'content-length': '123',
14
- * 'content-type': 'text/plain',
15
- * 'connection': 'keep-alive',
16
- * 'host': 'example.com',
17
- * 'accept': '*' }
12
+ * ```json
13
+ * { "content-length": "123",
14
+ * "content-type": "text/plain",
15
+ * "connection": "keep-alive",
16
+ * "host": "example.com",
17
+ * "accept": "*" }
18
18
  * ```
19
19
  *
20
20
  * Keys are lowercased. Values are not modified.
@@ -26,8 +26,8 @@
26
26
  *
27
27
  * See `message.headers` for details on how duplicate headers are handled.
28
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:
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
31
  *
32
32
  * ```js
33
33
  * [ 'ConTent-Length', '123456',
@@ -37,9 +37,10 @@
37
37
  * 'Host', 'example.com',
38
38
  * 'accepT', '*' ]
39
39
  * ```
40
- * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http.js)
40
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/http.js)
41
41
  */
42
42
  declare module "http" {
43
+ import { NonSharedBuffer } from "node:buffer";
43
44
  import * as stream from "node:stream";
44
45
  import { URL } from "node:url";
45
46
  import { LookupOptions } from "node:dns";
@@ -48,6 +49,7 @@ declare module "http" {
48
49
  // incoming headers will never contain number
49
50
  interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
50
51
  accept?: string | undefined;
52
+ "accept-encoding"?: string | undefined;
51
53
  "accept-language"?: string | undefined;
52
54
  "accept-patch"?: string | undefined;
53
55
  "accept-ranges"?: string | undefined;
@@ -94,6 +96,10 @@ declare module "http" {
94
96
  range?: string | undefined;
95
97
  referer?: string | undefined;
96
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;
97
103
  "sec-websocket-accept"?: string | undefined;
98
104
  "sec-websocket-extensions"?: string | undefined;
99
105
  "sec-websocket-key"?: string | undefined;
@@ -141,6 +147,7 @@ declare module "http" {
141
147
  "content-range"?: string | undefined;
142
148
  "content-security-policy"?: string | undefined;
143
149
  "content-security-policy-report-only"?: string | undefined;
150
+ "content-type"?: string | undefined;
144
151
  cookie?: string | string[] | undefined;
145
152
  dav?: string | string[] | undefined;
146
153
  dnt?: string | undefined;
@@ -161,7 +168,7 @@ declare module "http" {
161
168
  location?: string | undefined;
162
169
  "max-forwards"?: string | undefined;
163
170
  origin?: string | undefined;
164
- prgama?: string | string[] | undefined;
171
+ pragma?: string | string[] | undefined;
165
172
  "proxy-authenticate"?: string | string[] | undefined;
166
173
  "proxy-authorization"?: string | undefined;
167
174
  "public-key-pins"?: string | undefined;
@@ -194,18 +201,19 @@ declare module "http" {
194
201
  "x-frame-options"?: string | undefined;
195
202
  "x-xss-protection"?: string | undefined;
196
203
  }
197
- interface ClientRequestArgs {
204
+ interface ClientRequestArgs extends Pick<LookupOptions, "hints"> {
198
205
  _defaultAgent?: Agent | undefined;
199
206
  agent?: Agent | boolean | undefined;
200
207
  auth?: string | null | undefined;
201
- // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
202
208
  createConnection?:
203
- | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket)
209
+ | ((
210
+ options: ClientRequestArgs,
211
+ oncreate: (err: Error | null, socket: stream.Duplex) => void,
212
+ ) => stream.Duplex | null | undefined)
204
213
  | undefined;
205
214
  defaultPort?: number | string | undefined;
206
215
  family?: number | undefined;
207
- headers?: OutgoingHttpHeaders | undefined;
208
- hints?: LookupOptions["hints"];
216
+ headers?: OutgoingHttpHeaders | readonly string[] | undefined;
209
217
  host?: string | null | undefined;
210
218
  hostname?: string | null | undefined;
211
219
  insecureHTTPParser?: boolean | undefined;
@@ -220,16 +228,17 @@ declare module "http" {
220
228
  path?: string | null | undefined;
221
229
  port?: number | string | null | undefined;
222
230
  protocol?: string | null | undefined;
231
+ setDefaultHeaders?: boolean | undefined;
223
232
  setHost?: boolean | undefined;
224
233
  signal?: AbortSignal | undefined;
225
234
  socketPath?: string | undefined;
226
235
  timeout?: number | undefined;
227
236
  uniqueHeaders?: Array<string | string[]> | undefined;
228
- joinDuplicateHeaders?: boolean;
237
+ joinDuplicateHeaders?: boolean | undefined;
229
238
  }
230
239
  interface ServerOptions<
231
240
  Request extends typeof IncomingMessage = typeof IncomingMessage,
232
- Response extends typeof ServerResponse = typeof ServerResponse,
241
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
233
242
  > {
234
243
  /**
235
244
  * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
@@ -251,7 +260,7 @@ declare module "http" {
251
260
  * @default false
252
261
  * @since v18.14.0
253
262
  */
254
- joinDuplicateHeaders?: boolean;
263
+ joinDuplicateHeaders?: boolean | undefined;
255
264
  /**
256
265
  * The number of milliseconds of inactivity a server needs to wait for additional incoming data,
257
266
  * after it has finished writing the last response, before a socket will be destroyed.
@@ -260,11 +269,25 @@ declare module "http" {
260
269
  * @since v18.0.0
261
270
  */
262
271
  keepAliveTimeout?: number | undefined;
272
+ /**
273
+ * An additional buffer time added to the
274
+ * `server.keepAliveTimeout` to extend the internal socket timeout.
275
+ * @since 24.6.0
276
+ * @default 1000
277
+ */
278
+ keepAliveTimeoutBuffer?: number | undefined;
263
279
  /**
264
280
  * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
265
281
  * @default 30000
266
282
  */
267
283
  connectionsCheckingInterval?: number | undefined;
284
+ /**
285
+ * Sets the timeout value in milliseconds for receiving the complete HTTP headers from the client.
286
+ * See {@link Server.headersTimeout} for more information.
287
+ * @default 60000
288
+ * @since 18.0.0
289
+ */
290
+ headersTimeout?: number | undefined;
268
291
  /**
269
292
  * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
270
293
  * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`.
@@ -280,9 +303,8 @@ declare module "http" {
280
303
  */
281
304
  insecureHTTPParser?: boolean | undefined;
282
305
  /**
283
- * Optionally overrides the value of
284
- * `--max-http-header-size` for requests received by this server, i.e.
285
- * the maximum length of request headers in bytes.
306
+ * Optionally overrides the value of `--max-http-header-size` for requests received by
307
+ * this server, i.e. the maximum length of request headers in bytes.
286
308
  * @default 16384
287
309
  * @since v13.3.0
288
310
  */
@@ -293,6 +315,13 @@ declare module "http" {
293
315
  * @since v16.5.0
294
316
  */
295
317
  noDelay?: boolean | undefined;
318
+ /**
319
+ * If set to `true`, it forces the server to respond with a 400 (Bad Request) status code
320
+ * to any HTTP/1.1 request message that lacks a Host header (as mandated by the specification).
321
+ * @default true
322
+ * @since 20.0.0
323
+ */
324
+ requireHostHeader?: boolean | undefined;
296
325
  /**
297
326
  * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
298
327
  * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
@@ -311,17 +340,42 @@ declare module "http" {
311
340
  * If the header's value is an array, the items will be joined using `; `.
312
341
  */
313
342
  uniqueHeaders?: Array<string | string[]> | undefined;
343
+ /**
344
+ * A callback which receives an
345
+ * incoming request and returns a boolean, to control which upgrade attempts
346
+ * should be accepted. Accepted upgrades will fire an `'upgrade'` event (or
347
+ * their sockets will be destroyed, if no listener is registered) while
348
+ * rejected upgrades will fire a `'request'` event like any non-upgrade
349
+ * request.
350
+ * @since v24.9.0
351
+ * @default () => server.listenerCount('upgrade') > 0
352
+ */
353
+ shouldUpgradeCallback?: ((request: InstanceType<Request>) => boolean) | undefined;
354
+ /**
355
+ * If set to `true`, an error is thrown when writing to an HTTP response which does not have a body.
356
+ * @default false
357
+ * @since v18.17.0, v20.2.0
358
+ */
359
+ rejectNonStandardBodyWrites?: boolean | undefined;
360
+ /**
361
+ * If set to `true`, requests without `Content-Length` or `Transfer-Encoding` headers (indicating no body)
362
+ * will be initialized with an already-ended body stream, so they will never emit any stream events
363
+ * (like `'data'` or `'end'`). You can use `req.readableEnded` to detect this case.
364
+ * @default false
365
+ * @since v24.12.0
366
+ */
367
+ optimizeEmptyRequests?: boolean | undefined;
314
368
  }
315
369
  type RequestListener<
316
370
  Request extends typeof IncomingMessage = typeof IncomingMessage,
317
- Response extends typeof ServerResponse = typeof ServerResponse,
371
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
318
372
  > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
319
373
  /**
320
374
  * @since v0.1.17
321
375
  */
322
376
  class Server<
323
377
  Request extends typeof IncomingMessage = typeof IncomingMessage,
324
- Response extends typeof ServerResponse = typeof ServerResponse,
378
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
325
379
  > extends NetServer {
326
380
  constructor(requestListener?: RequestListener<Request, Response>);
327
381
  constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
@@ -339,8 +393,8 @@ declare module "http" {
339
393
  * @since v0.9.12
340
394
  * @param [msecs=0 (no timeout)]
341
395
  */
342
- setTimeout(msecs?: number, callback?: () => void): this;
343
- setTimeout(callback: () => void): this;
396
+ setTimeout(msecs?: number, callback?: (socket: Socket) => void): this;
397
+ setTimeout(callback: (socket: Socket) => void): this;
344
398
  /**
345
399
  * Limits maximum incoming headers count. If set to 0, no limit will be applied.
346
400
  * @since v0.7.0
@@ -385,12 +439,18 @@ declare module "http" {
385
439
  /**
386
440
  * The number of milliseconds of inactivity a server needs to wait for additional
387
441
  * incoming data, after it has finished writing the last response, before a socket
388
- * will be destroyed. If the server receives new data before the keep-alive
389
- * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
442
+ * will be destroyed.
443
+ *
444
+ * This timeout value is combined with the
445
+ * `server.keepAliveTimeoutBuffer` option to determine the actual socket
446
+ * timeout, calculated as:
447
+ * socketTimeout = keepAliveTimeout + keepAliveTimeoutBuffer
448
+ * If the server receives new data before the keep-alive timeout has fired, it
449
+ * will reset the regular inactivity timeout, i.e., `server.timeout`.
390
450
  *
391
451
  * A value of `0` will disable the keep-alive timeout behavior on incoming
392
452
  * connections.
393
- * A value of `0` makes the http server behave similarly to Node.js versions prior
453
+ * A value of `0` makes the HTTP server behave similarly to Node.js versions prior
394
454
  * to 8.0.0, which did not have a keep-alive timeout.
395
455
  *
396
456
  * The socket timeout logic is set up on connection, so changing this value only
@@ -398,6 +458,18 @@ declare module "http" {
398
458
  * @since v8.0.0
399
459
  */
400
460
  keepAliveTimeout: number;
461
+ /**
462
+ * An additional buffer time added to the
463
+ * `server.keepAliveTimeout` to extend the internal socket timeout.
464
+ *
465
+ * This buffer helps reduce connection reset (`ECONNRESET`) errors by increasing
466
+ * the socket timeout slightly beyond the advertised keep-alive timeout.
467
+ *
468
+ * This option applies only to new incoming connections.
469
+ * @since v24.6.0
470
+ * @default 1000
471
+ */
472
+ keepAliveTimeoutBuffer: number;
401
473
  /**
402
474
  * Sets the timeout value in milliseconds for receiving the entire request from
403
475
  * the client.
@@ -432,13 +504,13 @@ declare module "http" {
432
504
  addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
433
505
  addListener(
434
506
  event: "connect",
435
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
507
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
436
508
  ): this;
437
509
  addListener(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
438
510
  addListener(event: "request", listener: RequestListener<Request, Response>): this;
439
511
  addListener(
440
512
  event: "upgrade",
441
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
513
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
442
514
  ): this;
443
515
  emit(event: string, ...args: any[]): boolean;
444
516
  emit(event: "close"): boolean;
@@ -456,14 +528,14 @@ declare module "http" {
456
528
  res: InstanceType<Response> & { req: InstanceType<Request> },
457
529
  ): boolean;
458
530
  emit(event: "clientError", err: Error, socket: stream.Duplex): boolean;
459
- emit(event: "connect", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
531
+ emit(event: "connect", req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer): boolean;
460
532
  emit(event: "dropRequest", req: InstanceType<Request>, socket: stream.Duplex): boolean;
461
533
  emit(
462
534
  event: "request",
463
535
  req: InstanceType<Request>,
464
536
  res: InstanceType<Response> & { req: InstanceType<Request> },
465
537
  ): boolean;
466
- emit(event: "upgrade", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
538
+ emit(event: "upgrade", req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer): boolean;
467
539
  on(event: string, listener: (...args: any[]) => void): this;
468
540
  on(event: "close", listener: () => void): this;
469
541
  on(event: "connection", listener: (socket: Socket) => void): this;
@@ -472,10 +544,16 @@ declare module "http" {
472
544
  on(event: "checkContinue", listener: RequestListener<Request, Response>): this;
473
545
  on(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
474
546
  on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
475
- on(event: "connect", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
547
+ on(
548
+ event: "connect",
549
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
550
+ ): this;
476
551
  on(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
477
552
  on(event: "request", listener: RequestListener<Request, Response>): this;
478
- on(event: "upgrade", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
553
+ on(
554
+ event: "upgrade",
555
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
556
+ ): this;
479
557
  once(event: string, listener: (...args: any[]) => void): this;
480
558
  once(event: "close", listener: () => void): this;
481
559
  once(event: "connection", listener: (socket: Socket) => void): this;
@@ -486,13 +564,13 @@ declare module "http" {
486
564
  once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
487
565
  once(
488
566
  event: "connect",
489
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
567
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
490
568
  ): this;
491
569
  once(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
492
570
  once(event: "request", listener: RequestListener<Request, Response>): this;
493
571
  once(
494
572
  event: "upgrade",
495
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
573
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
496
574
  ): this;
497
575
  prependListener(event: string, listener: (...args: any[]) => void): this;
498
576
  prependListener(event: "close", listener: () => void): this;
@@ -504,7 +582,7 @@ declare module "http" {
504
582
  prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
505
583
  prependListener(
506
584
  event: "connect",
507
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
585
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
508
586
  ): this;
509
587
  prependListener(
510
588
  event: "dropRequest",
@@ -513,7 +591,7 @@ declare module "http" {
513
591
  prependListener(event: "request", listener: RequestListener<Request, Response>): this;
514
592
  prependListener(
515
593
  event: "upgrade",
516
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
594
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
517
595
  ): this;
518
596
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
519
597
  prependOnceListener(event: "close", listener: () => void): this;
@@ -525,7 +603,7 @@ declare module "http" {
525
603
  prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
526
604
  prependOnceListener(
527
605
  event: "connect",
528
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
606
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
529
607
  ): this;
530
608
  prependOnceListener(
531
609
  event: "dropRequest",
@@ -534,7 +612,7 @@ declare module "http" {
534
612
  prependOnceListener(event: "request", listener: RequestListener<Request, Response>): this;
535
613
  prependOnceListener(
536
614
  event: "upgrade",
537
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
615
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: NonSharedBuffer) => void,
538
616
  ): this;
539
617
  }
540
618
  /**
@@ -573,7 +651,7 @@ declare module "http" {
573
651
  readonly socket: Socket | null;
574
652
  constructor();
575
653
  /**
576
- * Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
654
+ * Once a socket is associated with the message and is connected, `socket.setTimeout()` will be called with `msecs` as the first parameter.
577
655
  * @since v0.9.12
578
656
  * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
579
657
  */
@@ -588,12 +666,48 @@ declare module "http" {
588
666
  */
589
667
  setHeader(name: string, value: number | string | readonly string[]): this;
590
668
  /**
591
- * Append a single header value for the header object.
669
+ * Sets multiple header values for implicit headers. headers must be an instance of
670
+ * `Headers` or `Map`, if a header already exists in the to-be-sent headers, its
671
+ * value will be replaced.
592
672
  *
593
- * If the value is an array, this is equivalent of calling this method multiple
673
+ * ```js
674
+ * const headers = new Headers({ foo: 'bar' });
675
+ * outgoingMessage.setHeaders(headers);
676
+ * ```
677
+ *
678
+ * or
679
+ *
680
+ * ```js
681
+ * const headers = new Map([['foo', 'bar']]);
682
+ * outgoingMessage.setHeaders(headers);
683
+ * ```
684
+ *
685
+ * When headers have been set with `outgoingMessage.setHeaders()`, they will be
686
+ * merged with any headers passed to `response.writeHead()`, with the headers passed
687
+ * to `response.writeHead()` given precedence.
688
+ *
689
+ * ```js
690
+ * // Returns content-type = text/plain
691
+ * const server = http.createServer((req, res) => {
692
+ * const headers = new Headers({ 'Content-Type': 'text/html' });
693
+ * res.setHeaders(headers);
694
+ * res.writeHead(200, { 'Content-Type': 'text/plain' });
695
+ * res.end('ok');
696
+ * });
697
+ * ```
698
+ *
699
+ * @since v19.6.0, v18.15.0
700
+ * @param name Header name
701
+ * @param value Header value
702
+ */
703
+ setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
704
+ /**
705
+ * Append a single header value to the header object.
706
+ *
707
+ * If the value is an array, this is equivalent to calling this method multiple
594
708
  * times.
595
709
  *
596
- * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`.
710
+ * If there were no previous values for the header, this is equivalent to calling `outgoingMessage.setHeader(name, value)`.
597
711
  *
598
712
  * Depending of the value of `options.uniqueHeaders` when the client request or the
599
713
  * server were created, this will end up in the header being sent multiple times or
@@ -689,7 +803,7 @@ declare module "http" {
689
803
  * packet.
690
804
  *
691
805
  * It is usually desired (it saves a TCP round-trip), but not when the first
692
- * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
806
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()` bypasses the optimization and kickstarts the message.
693
807
  * @since v1.6.0
694
808
  */
695
809
  flushHeaders(): void;
@@ -730,7 +844,7 @@ declare module "http" {
730
844
  */
731
845
  statusMessage: string;
732
846
  /**
733
- * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal.
847
+ * If set to `true`, Node.js will check whether the `Content-Length` header value and the size of the body, in bytes, are equal.
734
848
  * Mismatching the `Content-Length` header value will result
735
849
  * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
736
850
  * @since v18.10.0, v16.18.0
@@ -741,7 +855,7 @@ declare module "http" {
741
855
  detachSocket(socket: Socket): void;
742
856
  /**
743
857
  * Sends an HTTP/1.1 100 Continue message to the client, indicating that
744
- * the request body should be sent. See the `'checkContinue'` event on`Server`.
858
+ * the request body should be sent. See the `'checkContinue'` event on `Server`.
745
859
  * @since v0.3.0
746
860
  */
747
861
  writeContinue(callback?: () => void): void;
@@ -833,7 +947,7 @@ declare module "http" {
833
947
  * been transmitted are equal or not.
834
948
  *
835
949
  * Attempting to set a header field name or value that contains invalid characters
836
- * will result in a \[`Error`\]\[\] being thrown.
950
+ * will result in a `Error` being thrown.
837
951
  * @since v0.1.30
838
952
  */
839
953
  writeHead(
@@ -847,7 +961,7 @@ declare module "http" {
847
961
  * the request body should be sent.
848
962
  * @since v10.0.0
849
963
  */
850
- writeProcessing(): void;
964
+ writeProcessing(callback?: () => void): void;
851
965
  }
852
966
  interface InformationEvent {
853
967
  statusCode: number;
@@ -861,10 +975,10 @@ declare module "http" {
861
975
  /**
862
976
  * This object is created internally and returned from {@link request}. It
863
977
  * represents an _in-progress_ request whose header has already been queued. The
864
- * header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will
978
+ * header is still mutable using the `setHeader(name, value)`, `getHeader(name)`, `removeHeader(name)` API. The actual header will
865
979
  * be sent along with the first data chunk or when calling `request.end()`.
866
980
  *
867
- * To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response
981
+ * To get the response, add a listener for `'response'` to the request object. `'response'` will be emitted from the request object when the response
868
982
  * headers have been received. The `'response'` event is executed with one
869
983
  * argument which is an instance of {@link IncomingMessage}.
870
984
  *
@@ -880,10 +994,10 @@ declare module "http" {
880
994
  * the data is read it will consume memory that can eventually lead to a
881
995
  * 'process out of memory' error.
882
996
  *
883
- * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
997
+ * For backward compatibility, `res` will only emit `'error'` if there is an `'error'` listener registered.
884
998
  *
885
999
  * Set `Content-Length` header to limit the response body size.
886
- * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown,
1000
+ * If `response.strictContentLength` is set to `true`, mismatching the `Content-Length` header value will result in an `Error` being thrown,
887
1001
  * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
888
1002
  *
889
1003
  * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
@@ -894,7 +1008,7 @@ declare module "http" {
894
1008
  * The `request.aborted` property will be `true` if the request has
895
1009
  * been aborted.
896
1010
  * @since v0.11.14
897
- * @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
1011
+ * @deprecated Since v17.0.0, v16.12.0 - Check `destroyed` instead.
898
1012
  */
899
1013
  aborted: boolean;
900
1014
  /**
@@ -914,6 +1028,7 @@ declare module "http" {
914
1028
  *
915
1029
  * ```js
916
1030
  * import http from 'node:http';
1031
+ * const agent = new http.Agent({ keepAlive: true });
917
1032
  *
918
1033
  * // Server has a 5 seconds keep-alive timeout by default
919
1034
  * http
@@ -1018,7 +1133,7 @@ declare module "http" {
1018
1133
  addListener(event: "abort", listener: () => void): this;
1019
1134
  addListener(
1020
1135
  event: "connect",
1021
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1136
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1022
1137
  ): this;
1023
1138
  addListener(event: "continue", listener: () => void): this;
1024
1139
  addListener(event: "information", listener: (info: InformationEvent) => void): this;
@@ -1027,7 +1142,7 @@ declare module "http" {
1027
1142
  addListener(event: "timeout", listener: () => void): this;
1028
1143
  addListener(
1029
1144
  event: "upgrade",
1030
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1145
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1031
1146
  ): this;
1032
1147
  addListener(event: "close", listener: () => void): this;
1033
1148
  addListener(event: "drain", listener: () => void): this;
@@ -1040,13 +1155,19 @@ declare module "http" {
1040
1155
  * @deprecated
1041
1156
  */
1042
1157
  on(event: "abort", listener: () => void): this;
1043
- on(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1158
+ on(
1159
+ event: "connect",
1160
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1161
+ ): this;
1044
1162
  on(event: "continue", listener: () => void): this;
1045
1163
  on(event: "information", listener: (info: InformationEvent) => void): this;
1046
1164
  on(event: "response", listener: (response: IncomingMessage) => void): this;
1047
1165
  on(event: "socket", listener: (socket: Socket) => void): this;
1048
1166
  on(event: "timeout", listener: () => void): this;
1049
- on(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1167
+ on(
1168
+ event: "upgrade",
1169
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1170
+ ): this;
1050
1171
  on(event: "close", listener: () => void): this;
1051
1172
  on(event: "drain", listener: () => void): this;
1052
1173
  on(event: "error", listener: (err: Error) => void): this;
@@ -1058,13 +1179,19 @@ declare module "http" {
1058
1179
  * @deprecated
1059
1180
  */
1060
1181
  once(event: "abort", listener: () => void): this;
1061
- once(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1182
+ once(
1183
+ event: "connect",
1184
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1185
+ ): this;
1062
1186
  once(event: "continue", listener: () => void): this;
1063
1187
  once(event: "information", listener: (info: InformationEvent) => void): this;
1064
1188
  once(event: "response", listener: (response: IncomingMessage) => void): this;
1065
1189
  once(event: "socket", listener: (socket: Socket) => void): this;
1066
1190
  once(event: "timeout", listener: () => void): this;
1067
- once(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1191
+ once(
1192
+ event: "upgrade",
1193
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1194
+ ): this;
1068
1195
  once(event: "close", listener: () => void): this;
1069
1196
  once(event: "drain", listener: () => void): this;
1070
1197
  once(event: "error", listener: (err: Error) => void): this;
@@ -1078,7 +1205,7 @@ declare module "http" {
1078
1205
  prependListener(event: "abort", listener: () => void): this;
1079
1206
  prependListener(
1080
1207
  event: "connect",
1081
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1208
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1082
1209
  ): this;
1083
1210
  prependListener(event: "continue", listener: () => void): this;
1084
1211
  prependListener(event: "information", listener: (info: InformationEvent) => void): this;
@@ -1087,7 +1214,7 @@ declare module "http" {
1087
1214
  prependListener(event: "timeout", listener: () => void): this;
1088
1215
  prependListener(
1089
1216
  event: "upgrade",
1090
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1217
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1091
1218
  ): this;
1092
1219
  prependListener(event: "close", listener: () => void): this;
1093
1220
  prependListener(event: "drain", listener: () => void): this;
@@ -1102,7 +1229,7 @@ declare module "http" {
1102
1229
  prependOnceListener(event: "abort", listener: () => void): this;
1103
1230
  prependOnceListener(
1104
1231
  event: "connect",
1105
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1232
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1106
1233
  ): this;
1107
1234
  prependOnceListener(event: "continue", listener: () => void): this;
1108
1235
  prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this;
@@ -1111,7 +1238,7 @@ declare module "http" {
1111
1238
  prependOnceListener(event: "timeout", listener: () => void): this;
1112
1239
  prependOnceListener(
1113
1240
  event: "upgrade",
1114
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1241
+ listener: (response: IncomingMessage, socket: Socket, head: NonSharedBuffer) => void,
1115
1242
  ): this;
1116
1243
  prependOnceListener(event: "close", listener: () => void): this;
1117
1244
  prependOnceListener(event: "drain", listener: () => void): this;
@@ -1126,7 +1253,7 @@ declare module "http" {
1126
1253
  * access response
1127
1254
  * status, headers, and data.
1128
1255
  *
1129
- * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
1256
+ * Different from its `socket` value which is a subclass of `stream.Duplex`, the `IncomingMessage` itself extends `stream.Readable` and is created separately to
1130
1257
  * parse and emit the incoming HTTP headers and payload, as the underlying socket
1131
1258
  * may be reused multiple times in case of keep-alive.
1132
1259
  * @since v0.1.17
@@ -1145,7 +1272,7 @@ declare module "http" {
1145
1272
  * client response, the HTTP version of the connected-to server.
1146
1273
  * Probably either `'1.1'` or `'1.0'`.
1147
1274
  *
1148
- * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1275
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1149
1276
  * @since v0.1.1
1150
1277
  */
1151
1278
  httpVersion: string;
@@ -1210,8 +1337,8 @@ declare module "http" {
1210
1337
  * Duplicates in raw headers are handled in the following ways, depending on the
1211
1338
  * header name:
1212
1339
  *
1213
- * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
1214
- * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
1340
+ * * Duplicates of `age`, `authorization`, `content-length`, `content-type`, `etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`, `last-modified`, `location`,
1341
+ * `max-forwards`, `proxy-authorization`, `referer`, `retry-after`, `server`, or `user-agent` are discarded.
1215
1342
  * To allow duplicate values of the headers listed above to be joined,
1216
1343
  * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
1217
1344
  * information.
@@ -1305,29 +1432,32 @@ declare module "http" {
1305
1432
  * To parse the URL into its parts:
1306
1433
  *
1307
1434
  * ```js
1308
- * new URL(request.url, `http://${request.headers.host}`);
1435
+ * new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
1309
1436
  * ```
1310
1437
  *
1311
- * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
1438
+ * When `request.url` is `'/status?name=ryan'` and `process.env.HOST` is undefined:
1312
1439
  *
1313
1440
  * ```console
1314
1441
  * $ node
1315
- * > new URL(request.url, `http://${request.headers.host}`)
1442
+ * > new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`);
1316
1443
  * URL {
1317
- * href: 'http://localhost:3000/status?name=ryan',
1318
- * origin: 'http://localhost:3000',
1444
+ * href: 'http://localhost/status?name=ryan',
1445
+ * origin: 'http://localhost',
1319
1446
  * protocol: 'http:',
1320
1447
  * username: '',
1321
1448
  * password: '',
1322
- * host: 'localhost:3000',
1449
+ * host: 'localhost',
1323
1450
  * hostname: 'localhost',
1324
- * port: '3000',
1451
+ * port: '',
1325
1452
  * pathname: '/status',
1326
1453
  * search: '?name=ryan',
1327
1454
  * searchParams: URLSearchParams { 'name' => 'ryan' },
1328
1455
  * hash: ''
1329
1456
  * }
1330
1457
  * ```
1458
+ *
1459
+ * 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
1460
+ * validation is used, as clients may specify a custom `Host` header.
1331
1461
  * @since v0.1.90
1332
1462
  */
1333
1463
  url?: string | undefined;
@@ -1346,13 +1476,21 @@ declare module "http" {
1346
1476
  */
1347
1477
  statusMessage?: string | undefined;
1348
1478
  /**
1349
- * 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
1479
+ * 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
1350
1480
  * as an argument to any listeners on the event.
1351
1481
  * @since v0.3.0
1352
1482
  */
1353
1483
  destroy(error?: Error): this;
1354
1484
  }
1355
- interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1485
+ interface ProxyEnv extends NodeJS.ProcessEnv {
1486
+ HTTP_PROXY?: string | undefined;
1487
+ HTTPS_PROXY?: string | undefined;
1488
+ NO_PROXY?: string | undefined;
1489
+ http_proxy?: string | undefined;
1490
+ https_proxy?: string | undefined;
1491
+ no_proxy?: string | undefined;
1492
+ }
1493
+ interface AgentOptions extends NodeJS.PartialOptions<TcpSocketConnectOpts> {
1356
1494
  /**
1357
1495
  * Keep sockets around in a pool to be used by other requests in the future. Default = false
1358
1496
  */
@@ -1362,6 +1500,16 @@ declare module "http" {
1362
1500
  * Only relevant if keepAlive is set to true.
1363
1501
  */
1364
1502
  keepAliveMsecs?: number | undefined;
1503
+ /**
1504
+ * Milliseconds to subtract from
1505
+ * the server-provided `keep-alive: timeout=...` hint when determining socket
1506
+ * expiration time. This buffer helps ensure the agent closes the socket
1507
+ * slightly before the server does, reducing the chance of sending a request
1508
+ * on a socket that’s about to be closed by the server.
1509
+ * @since v24.7.0
1510
+ * @default 1000
1511
+ */
1512
+ agentKeepAliveTimeoutBuffer?: number | undefined;
1365
1513
  /**
1366
1514
  * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1367
1515
  */
@@ -1383,6 +1531,22 @@ declare module "http" {
1383
1531
  * @default `lifo`
1384
1532
  */
1385
1533
  scheduling?: "fifo" | "lifo" | undefined;
1534
+ /**
1535
+ * Environment variables for proxy configuration. See
1536
+ * [Built-in Proxy Support](https://nodejs.org/docs/latest-v24.x/api/http.html#built-in-proxy-support) for details.
1537
+ * @since v24.5.0
1538
+ */
1539
+ proxyEnv?: ProxyEnv | undefined;
1540
+ /**
1541
+ * Default port to use when the port is not specified in requests.
1542
+ * @since v24.5.0
1543
+ */
1544
+ defaultPort?: number | undefined;
1545
+ /**
1546
+ * The protocol to use for the agent.
1547
+ * @since v24.5.0
1548
+ */
1549
+ protocol?: string | undefined;
1386
1550
  }
1387
1551
  /**
1388
1552
  * An `Agent` is responsible for managing connection persistence
@@ -1390,7 +1554,7 @@ declare module "http" {
1390
1554
  * for a given host and port, reusing a single socket connection for each
1391
1555
  * until the queue is empty, at which time the socket is either destroyed
1392
1556
  * or put into a pool where it is kept to be used again for requests to the
1393
- * same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`.
1557
+ * same host and port. Whether it is destroyed or pooled depends on the `keepAlive` `option`.
1394
1558
  *
1395
1559
  * Pooled connections have TCP Keep-Alive enabled for them, but servers may
1396
1560
  * still close idle connections, in which case they will be removed from the
@@ -1421,7 +1585,7 @@ declare module "http" {
1421
1585
  * });
1422
1586
  * ```
1423
1587
  *
1424
- * 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
1588
+ * 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
1425
1589
  * will be used
1426
1590
  * for the client connection.
1427
1591
  *
@@ -1437,6 +1601,17 @@ declare module "http" {
1437
1601
  * // Do stuff with response
1438
1602
  * });
1439
1603
  * ```
1604
+ *
1605
+ * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v24.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
1606
+ *
1607
+ * To configure any of them, a custom {@link Agent} instance must be created.
1608
+ *
1609
+ * ```js
1610
+ * import http from 'node:http';
1611
+ * const keepAliveAgent = new http.Agent({ keepAlive: true });
1612
+ * options.agent = keepAliveAgent;
1613
+ * http.request(options, onResponseCallback)
1614
+ * ```
1440
1615
  * @since v0.3.4
1441
1616
  */
1442
1617
  class Agent extends EventEmitter {
@@ -1479,7 +1654,7 @@ declare module "http" {
1479
1654
  * sockets. Do not modify.
1480
1655
  * @since v0.5.9
1481
1656
  */
1482
- readonly requests: NodeJS.ReadOnlyDict<IncomingMessage[]>;
1657
+ readonly requests: NodeJS.ReadOnlyDict<ClientRequest[]>;
1483
1658
  constructor(opts?: AgentOptions);
1484
1659
  /**
1485
1660
  * Destroy any sockets that are currently in use by the agent.
@@ -1492,6 +1667,79 @@ declare module "http" {
1492
1667
  * @since v0.11.4
1493
1668
  */
1494
1669
  destroy(): void;
1670
+ /**
1671
+ * Produces a socket/stream to be used for HTTP requests.
1672
+ *
1673
+ * By default, this function behaves identically to `net.createConnection()`, synchronously
1674
+ * returning the created socket. The optional `callback` parameter in the signature is not
1675
+ * used by this default implementation.
1676
+ *
1677
+ * However, custom agents may override this method to provide greater flexibility,
1678
+ * for example, to create sockets asynchronously. When overriding `createConnection`:
1679
+ *
1680
+ * 1. **Synchronous socket creation**: The overriding method can return the socket/stream directly.
1681
+ * 2. **Asynchronous socket creation**: The overriding method can accept the `callback` and pass
1682
+ * the created socket/stream to it (e.g., `callback(null, newSocket)`). If an error occurs during
1683
+ * socket creation, it should be passed as the first argument to the `callback` (e.g., `callback(err)`).
1684
+ *
1685
+ * The agent will call the provided `createConnection` function with `options` and this internal
1686
+ * `callback`. The `callback` provided by the agent has a signature of `(err, stream)`.
1687
+ * @since v0.11.4
1688
+ * @param options Options containing connection details. Check `net.createConnection()`
1689
+ * for the format of the options. For custom agents, this object is passed
1690
+ * to the custom `createConnection` function.
1691
+ * @param callback (Optional, primarily for custom agents) A function to be called by a custom
1692
+ * `createConnection` implementation when the socket is created, especially for
1693
+ * asynchronous operations.
1694
+ * @returns `stream.Duplex` The created socket. This is returned by the default implementation
1695
+ * or by a custom synchronous `createConnection` implementation. If a
1696
+ * custom `createConnection` uses the `callback` for asynchronous operation,
1697
+ * this return value might not be the primary way to obtain the socket.
1698
+ */
1699
+ createConnection(
1700
+ options: ClientRequestArgs,
1701
+ callback?: (err: Error | null, stream: stream.Duplex) => void,
1702
+ ): stream.Duplex | null | undefined;
1703
+ /**
1704
+ * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
1705
+ *
1706
+ * ```js
1707
+ * socket.setKeepAlive(true, this.keepAliveMsecs);
1708
+ * socket.unref();
1709
+ * return true;
1710
+ * ```
1711
+ *
1712
+ * This method can be overridden by a particular `Agent` subclass. If this
1713
+ * method returns a falsy value, the socket will be destroyed instead of persisting
1714
+ * it for use with the next request.
1715
+ *
1716
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1717
+ * @since v8.1.0
1718
+ */
1719
+ keepSocketAlive(socket: stream.Duplex): void;
1720
+ /**
1721
+ * Called when `socket` is attached to `request` after being persisted because of
1722
+ * the keep-alive options. Default behavior is to:
1723
+ *
1724
+ * ```js
1725
+ * socket.ref();
1726
+ * ```
1727
+ *
1728
+ * This method can be overridden by a particular `Agent` subclass.
1729
+ *
1730
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1731
+ * @since v8.1.0
1732
+ */
1733
+ reuseSocket(socket: stream.Duplex, request: ClientRequest): void;
1734
+ /**
1735
+ * Get a unique name for a set of request options, to determine whether a
1736
+ * connection can be reused. For an HTTP agent, this returns`host:port:localAddress` or `host:port:localAddress:family`. For an HTTPS agent,
1737
+ * the name includes the CA, cert, ciphers, and other HTTPS/TLS-specific options
1738
+ * that determine socket reusability.
1739
+ * @since v0.11.4
1740
+ * @param options A set of options providing information for name generation
1741
+ */
1742
+ getName(options?: ClientRequestArgs): string;
1495
1743
  }
1496
1744
  const METHODS: string[];
1497
1745
  const STATUS_CODES: {
@@ -1538,11 +1786,11 @@ declare module "http" {
1538
1786
  */
1539
1787
  function createServer<
1540
1788
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1541
- Response extends typeof ServerResponse = typeof ServerResponse,
1789
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1542
1790
  >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1543
1791
  function createServer<
1544
1792
  Request extends typeof IncomingMessage = typeof IncomingMessage,
1545
- Response extends typeof ServerResponse = typeof ServerResponse,
1793
+ Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse,
1546
1794
  >(
1547
1795
  options: ServerOptions<Request, Response>,
1548
1796
  requestListener?: RequestListener<Request, Response>,
@@ -1559,7 +1807,7 @@ declare module "http" {
1559
1807
  * `url` can be a string or a `URL` object. If `url` is a
1560
1808
  * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
1561
1809
  *
1562
- * If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence.
1810
+ * If both `url` and `options` are specified, the objects are merged, with the `options` properties taking precedence.
1563
1811
  *
1564
1812
  * The optional `callback` parameter will be added as a one-time listener for
1565
1813
  * the `'response'` event.
@@ -1659,7 +1907,7 @@ declare module "http" {
1659
1907
  * the following events will be emitted in the following order:
1660
1908
  *
1661
1909
  * * `'socket'`
1662
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1910
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
1663
1911
  * * `'close'`
1664
1912
  *
1665
1913
  * In the case of a premature connection close after the response is received,
@@ -1670,15 +1918,15 @@ declare module "http" {
1670
1918
  * * `'data'` any number of times, on the `res` object
1671
1919
  * * (connection closed here)
1672
1920
  * * `'aborted'` on the `res` object
1673
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
1674
1921
  * * `'close'`
1922
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`
1675
1923
  * * `'close'` on the `res` object
1676
1924
  *
1677
1925
  * If `req.destroy()` is called before a socket is assigned, the following
1678
1926
  * events will be emitted in the following order:
1679
1927
  *
1680
1928
  * * (`req.destroy()` called here)
1681
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1929
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1682
1930
  * * `'close'`
1683
1931
  *
1684
1932
  * If `req.destroy()` is called before the connection succeeds, the following
@@ -1686,7 +1934,7 @@ declare module "http" {
1686
1934
  *
1687
1935
  * * `'socket'`
1688
1936
  * * (`req.destroy()` called here)
1689
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1937
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1690
1938
  * * `'close'`
1691
1939
  *
1692
1940
  * If `req.destroy()` is called after the response is received, the following
@@ -1697,8 +1945,8 @@ declare module "http" {
1697
1945
  * * `'data'` any number of times, on the `res` object
1698
1946
  * * (`req.destroy()` called here)
1699
1947
  * * `'aborted'` on the `res` object
1700
- * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1701
1948
  * * `'close'`
1949
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1702
1950
  * * `'close'` on the `res` object
1703
1951
  *
1704
1952
  * If `req.abort()` is called before a socket is assigned, the following
@@ -1714,7 +1962,7 @@ declare module "http" {
1714
1962
  * * `'socket'`
1715
1963
  * * (`req.abort()` called here)
1716
1964
  * * `'abort'`
1717
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1965
+ * * `'error'` with an error with message `'Error: socket hang up'` and code `'ECONNRESET'`
1718
1966
  * * `'close'`
1719
1967
  *
1720
1968
  * If `req.abort()` is called after the response is received, the following
@@ -1726,16 +1974,16 @@ declare module "http" {
1726
1974
  * * (`req.abort()` called here)
1727
1975
  * * `'abort'`
1728
1976
  * * `'aborted'` on the `res` object
1729
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1977
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'` and code `'ECONNRESET'`.
1730
1978
  * * `'close'`
1731
1979
  * * `'close'` on the `res` object
1732
1980
  *
1733
1981
  * Setting the `timeout` option or using the `setTimeout()` function will
1734
1982
  * not abort the request or do anything besides add a `'timeout'` event.
1735
1983
  *
1736
- * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1984
+ * Passing an `AbortSignal` and then calling `abort()` on the corresponding `AbortController` will behave the same way as calling `.destroy()` on the
1737
1985
  * request. Specifically, the `'error'` event will be emitted with an error with
1738
- * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided.
1986
+ * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'` and the `cause`, if one was provided.
1739
1987
  * @since v0.3.6
1740
1988
  */
1741
1989
  function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
@@ -1746,7 +1994,7 @@ declare module "http" {
1746
1994
  ): ClientRequest;
1747
1995
  /**
1748
1996
  * Since most requests are GET requests without bodies, Node.js provides this
1749
- * 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
1997
+ * 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
1750
1998
  * consume the response
1751
1999
  * data for reasons stated in {@link ClientRequest} section.
1752
2000
  *
@@ -1807,14 +2055,13 @@ declare module "http" {
1807
2055
  function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1808
2056
  function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1809
2057
  /**
1810
- * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called.
2058
+ * Performs the low-level validations on the provided `name` that are done when `res.setHeader(name, value)` is called.
1811
2059
  *
1812
2060
  * Passing illegal value as `name` will result in a `TypeError` being thrown,
1813
2061
  * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1814
2062
  *
1815
2063
  * It is not necessary to use this method before passing headers to an HTTP request
1816
2064
  * or response. The HTTP module will automatically validate such headers.
1817
- * Examples:
1818
2065
  *
1819
2066
  * Example:
1820
2067
  *
@@ -1834,7 +2081,7 @@ declare module "http" {
1834
2081
  */
1835
2082
  function validateHeaderName(name: string): void;
1836
2083
  /**
1837
- * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called.
2084
+ * Performs the low-level validations on the provided `value` that are done when `res.setHeader(name, value)` is called.
1838
2085
  *
1839
2086
  * Passing illegal value as `value` will result in a `TypeError` being thrown.
1840
2087
  *
@@ -1876,12 +2123,31 @@ declare module "http" {
1876
2123
  * @param [max=1000]
1877
2124
  */
1878
2125
  function setMaxIdleHTTPParsers(max: number): void;
2126
+ /**
2127
+ * Global instance of `Agent` which is used as the default for all HTTP client
2128
+ * requests. Diverges from a default `Agent` configuration by having `keepAlive`
2129
+ * enabled and a `timeout` of 5 seconds.
2130
+ * @since v0.5.9
2131
+ */
1879
2132
  let globalAgent: Agent;
1880
2133
  /**
1881
2134
  * Read-only property specifying the maximum allowed size of HTTP headers in bytes.
1882
2135
  * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
1883
2136
  */
1884
2137
  const maxHeaderSize: number;
2138
+ /**
2139
+ * A browser-compatible implementation of `WebSocket`.
2140
+ * @since v22.5.0
2141
+ */
2142
+ const WebSocket: typeof import("undici-types").WebSocket;
2143
+ /**
2144
+ * @since v22.5.0
2145
+ */
2146
+ const CloseEvent: typeof import("undici-types").CloseEvent;
2147
+ /**
2148
+ * @since v22.5.0
2149
+ */
2150
+ const MessageEvent: typeof import("undici-types").MessageEvent;
1885
2151
  }
1886
2152
  declare module "node:http" {
1887
2153
  export * from "http";