@types/node 18.16.2 → 20.0.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 (95) hide show
  1. node/README.md +1 -1
  2. node/assert.d.ts +68 -73
  3. node/async_hooks.d.ts +62 -42
  4. node/buffer.d.ts +123 -95
  5. node/child_process.d.ts +50 -54
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +209 -220
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +25 -26
  11. node/dns/promises.d.ts +6 -6
  12. node/dns.d.ts +16 -16
  13. node/domain.d.ts +3 -3
  14. node/events.d.ts +60 -60
  15. node/fs/promises.d.ts +74 -48
  16. node/fs.d.ts +91 -81
  17. node/http.d.ts +147 -144
  18. node/http2.d.ts +42 -46
  19. node/https.d.ts +52 -153
  20. node/index.d.ts +1 -1
  21. node/inspector.d.ts +10 -3
  22. node/module.d.ts +5 -4
  23. node/net.d.ts +21 -18
  24. node/os.d.ts +22 -18
  25. node/package.json +2 -2
  26. node/path.d.ts +4 -4
  27. node/perf_hooks.d.ts +28 -15
  28. node/process.d.ts +43 -46
  29. node/punycode.d.ts +1 -1
  30. node/querystring.d.ts +5 -5
  31. node/readline/promises.d.ts +6 -4
  32. node/readline.d.ts +15 -15
  33. node/repl.d.ts +9 -9
  34. node/stream/consumers.d.ts +1 -1
  35. node/stream.d.ts +74 -136
  36. node/string_decoder.d.ts +6 -6
  37. node/test.d.ts +0 -76
  38. node/timers/promises.d.ts +3 -3
  39. node/timers.d.ts +2 -2
  40. node/tls.d.ts +29 -15
  41. node/trace_events.d.ts +20 -9
  42. node/ts4.8/assert.d.ts +68 -73
  43. node/ts4.8/async_hooks.d.ts +59 -31
  44. node/ts4.8/buffer.d.ts +123 -95
  45. node/ts4.8/child_process.d.ts +50 -54
  46. node/ts4.8/cluster.d.ts +12 -12
  47. node/ts4.8/console.d.ts +5 -5
  48. node/ts4.8/crypto.d.ts +209 -220
  49. node/ts4.8/dgram.d.ts +15 -15
  50. node/ts4.8/diagnostics_channel.d.ts +25 -26
  51. node/ts4.8/dns/promises.d.ts +6 -6
  52. node/ts4.8/dns.d.ts +16 -16
  53. node/ts4.8/domain.d.ts +3 -3
  54. node/ts4.8/events.d.ts +60 -60
  55. node/ts4.8/fs/promises.d.ts +72 -45
  56. node/ts4.8/fs.d.ts +81 -67
  57. node/ts4.8/http.d.ts +133 -126
  58. node/ts4.8/http2.d.ts +42 -46
  59. node/ts4.8/https.d.ts +52 -153
  60. node/ts4.8/inspector.d.ts +10 -3
  61. node/ts4.8/module.d.ts +5 -4
  62. node/ts4.8/net.d.ts +21 -18
  63. node/ts4.8/os.d.ts +22 -18
  64. node/ts4.8/path.d.ts +4 -4
  65. node/ts4.8/perf_hooks.d.ts +28 -15
  66. node/ts4.8/process.d.ts +43 -46
  67. node/ts4.8/punycode.d.ts +1 -1
  68. node/ts4.8/querystring.d.ts +5 -5
  69. node/ts4.8/readline/promises.d.ts +6 -4
  70. node/ts4.8/readline.d.ts +15 -15
  71. node/ts4.8/repl.d.ts +9 -9
  72. node/ts4.8/stream/consumers.d.ts +1 -1
  73. node/ts4.8/stream.d.ts +77 -139
  74. node/ts4.8/string_decoder.d.ts +6 -6
  75. node/ts4.8/test.d.ts +0 -75
  76. node/ts4.8/timers/promises.d.ts +3 -3
  77. node/ts4.8/timers.d.ts +2 -2
  78. node/ts4.8/tls.d.ts +29 -15
  79. node/ts4.8/trace_events.d.ts +20 -9
  80. node/ts4.8/tty.d.ts +4 -5
  81. node/ts4.8/url.d.ts +26 -36
  82. node/ts4.8/util.d.ts +143 -116
  83. node/ts4.8/v8.d.ts +107 -16
  84. node/ts4.8/vm.d.ts +292 -42
  85. node/ts4.8/wasi.d.ts +8 -14
  86. node/ts4.8/worker_threads.d.ts +32 -34
  87. node/ts4.8/zlib.d.ts +11 -11
  88. node/tty.d.ts +4 -5
  89. node/url.d.ts +26 -36
  90. node/util.d.ts +146 -111
  91. node/v8.d.ts +110 -16
  92. node/vm.d.ts +292 -42
  93. node/wasi.d.ts +8 -14
  94. node/worker_threads.d.ts +32 -34
  95. node/zlib.d.ts +11 -11
node/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * To use the HTTP server and client one must `require('http')`.
2
+ * To use the HTTP server and client one must `require('node:http')`.
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.
@@ -37,7 +37,7 @@
37
37
  * 'Host', 'example.com',
38
38
  * 'accepT', '*' ]
39
39
  * ```
40
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js)
40
+ * @see [source](https://github.com/nodejs/node/blob/v20.0.0/lib/http.js)
41
41
  */
42
42
  declare module 'http' {
43
43
  import * as stream from 'node:stream';
@@ -329,7 +329,8 @@ declare module 'http' {
329
329
  */
330
330
  closeAllConnections(): void;
331
331
  /**
332
- * Closes all connections connected to this server which are not sending a request or waiting for a response.
332
+ * Closes all connections connected to this server which are not sending a request
333
+ * or waiting for a response.
333
334
  * @since v18.2.0
334
335
  */
335
336
  closeIdleConnections(): void;
@@ -341,16 +342,10 @@ declare module 'http' {
341
342
  addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
342
343
  addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
343
344
  addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
344
- addListener(
345
- event: 'connect',
346
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
347
- ): this;
345
+ addListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
348
346
  addListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
349
347
  addListener(event: 'request', listener: RequestListener<Request, Response>): this;
350
- addListener(
351
- event: 'upgrade',
352
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
353
- ): this;
348
+ addListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
354
349
  emit(event: string, ...args: any[]): boolean;
355
350
  emit(event: 'close'): boolean;
356
351
  emit(event: 'connection', socket: Socket): boolean;
@@ -395,16 +390,10 @@ declare module 'http' {
395
390
  once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
396
391
  once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
397
392
  once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
398
- once(
399
- event: 'connect',
400
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
401
- ): this;
393
+ once(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
402
394
  once(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
403
395
  once(event: 'request', listener: RequestListener<Request, Response>): this;
404
- once(
405
- event: 'upgrade',
406
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
407
- ): this;
396
+ once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
408
397
  prependListener(event: string, listener: (...args: any[]) => void): this;
409
398
  prependListener(event: 'close', listener: () => void): this;
410
399
  prependListener(event: 'connection', listener: (socket: Socket) => void): this;
@@ -413,19 +402,10 @@ declare module 'http' {
413
402
  prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
414
403
  prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
415
404
  prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
416
- prependListener(
417
- event: 'connect',
418
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
419
- ): this;
420
- prependListener(
421
- event: 'dropRequest',
422
- listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
423
- ): this;
405
+ prependListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
406
+ prependListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
424
407
  prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
425
- prependListener(
426
- event: 'upgrade',
427
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
428
- ): this;
408
+ prependListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
429
409
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
430
410
  prependOnceListener(event: 'close', listener: () => void): this;
431
411
  prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
@@ -434,23 +414,14 @@ declare module 'http' {
434
414
  prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
435
415
  prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
436
416
  prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
437
- prependOnceListener(
438
- event: 'connect',
439
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
440
- ): this;
441
- prependOnceListener(
442
- event: 'dropRequest',
443
- listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
444
- ): this;
417
+ prependOnceListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
418
+ prependOnceListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
445
419
  prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
446
- prependOnceListener(
447
- event: 'upgrade',
448
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
449
- ): this;
420
+ prependOnceListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
450
421
  }
451
422
  /**
452
- * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from
453
- * the perspective of the participants of HTTP transaction.
423
+ * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
424
+ * the perspective of the participants of an HTTP transaction.
454
425
  * @since v0.1.17
455
426
  */
456
427
  class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
@@ -469,7 +440,7 @@ declare module 'http' {
469
440
  */
470
441
  readonly headersSent: boolean;
471
442
  /**
472
- * Aliases of `outgoingMessage.socket`
443
+ * Alias of `outgoingMessage.socket`.
473
444
  * @since v0.3.0
474
445
  * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
475
446
  */
@@ -490,8 +461,9 @@ declare module 'http' {
490
461
  */
491
462
  setTimeout(msecs: number, callback?: () => void): this;
492
463
  /**
493
- * Sets a single header value for the header object.
494
- * If the header already exists in the to-be-sent headers, its value will be replaced. Use an array of strings to send multiple headers with the same name.
464
+ * Sets a single header value. If the header already exists in the to-be-sent
465
+ * headers, its value will be replaced. Use an array of strings to send multiple
466
+ * headers with the same name.
495
467
  * @since v0.4.0
496
468
  * @param name Header name
497
469
  * @param value Header value
@@ -500,20 +472,22 @@ declare module 'http' {
500
472
  /**
501
473
  * Append a single header value for the header object.
502
474
  *
503
- * If the value is an array, this is equivalent of calling this method multiple times.
475
+ * If the value is an array, this is equivalent of calling this method multiple
476
+ * times.
504
477
  *
505
478
  * If there were no previous value for the header, this is equivalent of calling `outgoingMessage.setHeader(name, value)`.
506
479
  *
507
- * Depending of the value of `options.uniqueHeaders` when the client request or the server were created,
508
- * this will end up in the header being sent multiple times or a single time with values joined using `; `.
480
+ * Depending of the value of `options.uniqueHeaders` when the client request or the
481
+ * server were created, this will end up in the header being sent multiple times or
482
+ * a single time with values joined using `; `.
509
483
  * @since v18.3.0, v16.17.0
510
484
  * @param name Header name
511
485
  * @param value Header value
512
486
  */
513
487
  appendHeader(name: string, value: string | ReadonlyArray<string>): this;
514
488
  /**
515
- * Gets the value of HTTP header with the given name. If such a name doesn't
516
- * exist in message, it will be `undefined`.
489
+ * Gets the value of the HTTP header with the given name. If that header is not
490
+ * set, the returned value will be `undefined`.
517
491
  * @since v0.4.0
518
492
  * @param name Name of header
519
493
  */
@@ -526,8 +500,8 @@ declare module 'http' {
526
500
  * values. All header names are lowercase.
527
501
  *
528
502
  * The object returned by the `outgoingMessage.getHeaders()` method does
529
- * not prototypically inherit from the JavaScript Object. This means that
530
- * typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`,
503
+ * not prototypically inherit from the JavaScript `Object`. This means that
504
+ * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
531
505
  * and others are not defined and will not work.
532
506
  *
533
507
  * ```js
@@ -541,8 +515,8 @@ declare module 'http' {
541
515
  */
542
516
  getHeaders(): OutgoingHttpHeaders;
543
517
  /**
544
- * Returns an array of names of headers of the outgoing outgoingMessage. All
545
- * names are lowercase.
518
+ * Returns an array containing the unique names of the current outgoing headers.
519
+ * All names are lowercase.
546
520
  * @since v7.7.0
547
521
  */
548
522
  getHeaderNames(): string[];
@@ -569,11 +543,11 @@ declare module 'http' {
569
543
  /**
570
544
  * Adds HTTP trailers (headers but at the end of the message) to the message.
571
545
  *
572
- * Trailers are **only** be emitted if the message is chunked encoded. If not,
573
- * the trailer will be silently discarded.
546
+ * Trailers will **only** be emitted if the message is chunked encoded. If not,
547
+ * the trailers will be silently discarded.
574
548
  *
575
549
  * HTTP requires the `Trailer` header to be sent to emit trailers,
576
- * with a list of header fields in its value, e.g.
550
+ * with a list of header field names in its value, e.g.
577
551
  *
578
552
  * ```js
579
553
  * message.writeHead(200, { 'Content-Type': 'text/plain',
@@ -589,7 +563,7 @@ declare module 'http' {
589
563
  */
590
564
  addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
591
565
  /**
592
- * Compulsorily flushes the message headers
566
+ * Flushes the message headers.
593
567
  *
594
568
  * For efficiency reason, Node.js normally buffers the message headers
595
569
  * until `outgoingMessage.end()` is called or the first chunk of message data
@@ -597,7 +571,7 @@ declare module 'http' {
597
571
  * packet.
598
572
  *
599
573
  * It is usually desired (it saves a TCP round-trip), but not when the first
600
- * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request.
574
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
601
575
  * @since v1.6.0
602
576
  */
603
577
  flushHeaders(): void;
@@ -638,10 +612,9 @@ declare module 'http' {
638
612
  */
639
613
  statusMessage: string;
640
614
  /**
641
- * If set to `true`, Node.js will check whether the `Content-Length` header value
642
- * and the size of the body, in bytes, are equal. Mismatching the
643
- * `Content-Length` header value will result in an `Error` being thrown,
644
- * identified by `code: 'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
615
+ * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal.
616
+ * Mismatching the `Content-Length` header value will result
617
+ * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
645
618
  * @since v18.10.0, v16.18.0
646
619
  */
647
620
  strictContentLength: boolean;
@@ -661,7 +634,7 @@ declare module 'http' {
661
634
  * early hints message. The optional `callback` argument will be called when
662
635
  * the response message has been written.
663
636
  *
664
- * Example:
637
+ * **Example**
665
638
  *
666
639
  * ```js
667
640
  * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
@@ -675,15 +648,14 @@ declare module 'http' {
675
648
  * ];
676
649
  * response.writeEarlyHints({
677
650
  * 'link': earlyHintsLinks,
678
- * 'x-trace-id': 'id for diagnostics'
651
+ * 'x-trace-id': 'id for diagnostics',
679
652
  * });
680
653
  *
681
654
  * const earlyHintsCallback = () => console.log('early hints message sent');
682
655
  * response.writeEarlyHints({
683
- * 'link': earlyHintsLinks
656
+ * 'link': earlyHintsLinks,
684
657
  * }, earlyHintsCallback);
685
658
  * ```
686
- *
687
659
  * @since v18.11.0
688
660
  * @param hints An object containing the values of headers
689
661
  * @param callback Will be called when the response message has been written
@@ -707,7 +679,7 @@ declare module 'http' {
707
679
  * response
708
680
  * .writeHead(200, {
709
681
  * 'Content-Length': Buffer.byteLength(body),
710
- * 'Content-Type': 'text/plain'
682
+ * 'Content-Type': 'text/plain',
711
683
  * })
712
684
  * .end(body);
713
685
  * ```
@@ -738,12 +710,12 @@ declare module 'http' {
738
710
  * });
739
711
  * ```
740
712
  *
741
- * `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
742
- * does not check whether `Content-Length` and the length of the body which has
713
+ * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
714
+ * will check whether `Content-Length` and the length of the body which has
743
715
  * been transmitted are equal or not.
744
716
  *
745
717
  * Attempting to set a header field name or value that contains invalid characters
746
- * will result in a `TypeError` being thrown.
718
+ * will result in a \[`Error`\]\[\] being thrown.
747
719
  * @since v0.1.30
748
720
  */
749
721
  writeHead(
@@ -753,7 +725,7 @@ declare module 'http' {
753
725
  ): this;
754
726
  writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
755
727
  /**
756
- * Sends an HTTP/1.1 102 Processing message to the client, indicating that
728
+ * Sends a HTTP/1.1 102 Processing message to the client, indicating that
757
729
  * the request body should be sent.
758
730
  * @since v10.0.0
759
731
  */
@@ -792,8 +764,11 @@ declare module 'http' {
792
764
  *
793
765
  * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
794
766
  *
795
- * Node.js does not check whether Content-Length and the length of the
796
- * body which has been transmitted are equal or not.
767
+ * Set `Content-Length` header to limit the response body size.
768
+ * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown,
769
+ * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
770
+ *
771
+ * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
797
772
  * @since v0.1.17
798
773
  */
799
774
  class ClientRequest extends OutgoingMessage {
@@ -820,7 +795,7 @@ declare module 'http' {
820
795
  * may run into a 'ECONNRESET' error.
821
796
  *
822
797
  * ```js
823
- * const http = require('http');
798
+ * const http = require('node:http');
824
799
  *
825
800
  * // Server has a 5 seconds keep-alive timeout by default
826
801
  * http
@@ -844,7 +819,7 @@ declare module 'http' {
844
819
  * automatic error retry base on it.
845
820
  *
846
821
  * ```js
847
- * const http = require('http');
822
+ * const http = require('node:http');
848
823
  * const agent = new http.Agent({ keepAlive: true });
849
824
  *
850
825
  * function retriableRequest() {
@@ -923,19 +898,13 @@ declare module 'http' {
923
898
  * @deprecated
924
899
  */
925
900
  addListener(event: 'abort', listener: () => void): this;
926
- addListener(
927
- event: 'connect',
928
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
929
- ): this;
901
+ addListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
930
902
  addListener(event: 'continue', listener: () => void): this;
931
903
  addListener(event: 'information', listener: (info: InformationEvent) => void): this;
932
904
  addListener(event: 'response', listener: (response: IncomingMessage) => void): this;
933
905
  addListener(event: 'socket', listener: (socket: Socket) => void): this;
934
906
  addListener(event: 'timeout', listener: () => void): this;
935
- addListener(
936
- event: 'upgrade',
937
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
938
- ): this;
907
+ addListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
939
908
  addListener(event: 'close', listener: () => void): this;
940
909
  addListener(event: 'drain', listener: () => void): this;
941
910
  addListener(event: 'error', listener: (err: Error) => void): this;
@@ -983,19 +952,13 @@ declare module 'http' {
983
952
  * @deprecated
984
953
  */
985
954
  prependListener(event: 'abort', listener: () => void): this;
986
- prependListener(
987
- event: 'connect',
988
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
989
- ): this;
955
+ prependListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
990
956
  prependListener(event: 'continue', listener: () => void): this;
991
957
  prependListener(event: 'information', listener: (info: InformationEvent) => void): this;
992
958
  prependListener(event: 'response', listener: (response: IncomingMessage) => void): this;
993
959
  prependListener(event: 'socket', listener: (socket: Socket) => void): this;
994
960
  prependListener(event: 'timeout', listener: () => void): this;
995
- prependListener(
996
- event: 'upgrade',
997
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
998
- ): this;
961
+ prependListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
999
962
  prependListener(event: 'close', listener: () => void): this;
1000
963
  prependListener(event: 'drain', listener: () => void): this;
1001
964
  prependListener(event: 'error', listener: (err: Error) => void): this;
@@ -1007,19 +970,13 @@ declare module 'http' {
1007
970
  * @deprecated
1008
971
  */
1009
972
  prependOnceListener(event: 'abort', listener: () => void): this;
1010
- prependOnceListener(
1011
- event: 'connect',
1012
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1013
- ): this;
973
+ prependOnceListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1014
974
  prependOnceListener(event: 'continue', listener: () => void): this;
1015
975
  prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this;
1016
976
  prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this;
1017
977
  prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this;
1018
978
  prependOnceListener(event: 'timeout', listener: () => void): this;
1019
- prependOnceListener(
1020
- event: 'upgrade',
1021
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1022
- ): this;
979
+ prependOnceListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1023
980
  prependOnceListener(event: 'close', listener: () => void): this;
1024
981
  prependOnceListener(event: 'drain', listener: () => void): this;
1025
982
  prependOnceListener(event: 'error', listener: (err: Error) => void): this;
@@ -1031,7 +988,7 @@ declare module 'http' {
1031
988
  /**
1032
989
  * 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
1033
990
  * access response
1034
- * status, headers and data.
991
+ * status, headers, and data.
1035
992
  *
1036
993
  * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
1037
994
  * parse and emit the incoming HTTP headers and payload, as the underlying socket
@@ -1069,7 +1026,7 @@ declare module 'http' {
1069
1026
  * const req = http.request({
1070
1027
  * host: '127.0.0.1',
1071
1028
  * port: 8080,
1072
- * method: 'POST'
1029
+ * method: 'POST',
1073
1030
  * }, (res) => {
1074
1031
  * res.resume();
1075
1032
  * res.on('end', () => {
@@ -1111,7 +1068,7 @@ declare module 'http' {
1111
1068
  * // { 'user-agent': 'curl/7.22.0',
1112
1069
  * // host: '127.0.0.1:8000',
1113
1070
  * // accept: '*' }
1114
- * console.log(request.getHeaders());
1071
+ * console.log(request.headers);
1115
1072
  * ```
1116
1073
  *
1117
1074
  * Duplicates in raw headers are handled in the following ways, depending on the
@@ -1119,14 +1076,18 @@ declare module 'http' {
1119
1076
  *
1120
1077
  * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
1121
1078
  * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
1079
+ * To allow duplicate values of the headers listed above to be joined,
1080
+ * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
1081
+ * information.
1122
1082
  * * `set-cookie` is always an array. Duplicates are added to the array.
1123
- * * For duplicate `cookie` headers, the values are joined together with '; '.
1124
- * * For all other headers, the values are joined together with ', '.
1083
+ * * For duplicate `cookie` headers, the values are joined together with `; `.
1084
+ * * For all other headers, the values are joined together with `, `.
1125
1085
  * @since v0.1.5
1126
1086
  */
1127
1087
  headers: IncomingHttpHeaders;
1128
1088
  /**
1129
- * Similar to `message.headers`, but there is no join logic and the values are always arrays of strings, even for headers received just once.
1089
+ * Similar to `message.headers`, but there is no join logic and the values are
1090
+ * always arrays of strings, even for headers received just once.
1130
1091
  *
1131
1092
  * ```js
1132
1093
  * // Prints something like:
@@ -1170,7 +1131,8 @@ declare module 'http' {
1170
1131
  */
1171
1132
  trailers: NodeJS.Dict<string>;
1172
1133
  /**
1173
- * Similar to `message.trailers`, but there is no join logic and the values are always arrays of strings, even for headers received just once.
1134
+ * Similar to `message.trailers`, but there is no join logic and the values are
1135
+ * always arrays of strings, even for headers received just once.
1174
1136
  * Only populated at the `'end'` event.
1175
1137
  * @since v18.3.0, v16.17.0
1176
1138
  */
@@ -1207,14 +1169,14 @@ declare module 'http' {
1207
1169
  * To parse the URL into its parts:
1208
1170
  *
1209
1171
  * ```js
1210
- * new URL(request.url, `http://${request.getHeaders().host}`);
1172
+ * new URL(request.url, `http://${request.headers.host}`);
1211
1173
  * ```
1212
1174
  *
1213
- * When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
1175
+ * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
1214
1176
  *
1215
1177
  * ```console
1216
1178
  * $ node
1217
- * > new URL(request.url, `http://${request.getHeaders().host}`)
1179
+ * > new URL(request.url, `http://${request.headers.host}`)
1218
1180
  * URL {
1219
1181
  * href: 'http://localhost:3000/status?name=ryan',
1220
1182
  * origin: 'http://localhost:3000',
@@ -1334,7 +1296,7 @@ declare module 'http' {
1334
1296
  * hostname: 'localhost',
1335
1297
  * port: 80,
1336
1298
  * path: '/',
1337
- * agent: false // Create a new agent just for this one request
1299
+ * agent: false, // Create a new agent just for this one request
1338
1300
  * }, (res) => {
1339
1301
  * // Do stuff with response
1340
1302
  * });
@@ -1439,10 +1401,10 @@ declare module 'http' {
1439
1401
  * upload a file with a POST request, then write to the `ClientRequest` object.
1440
1402
  *
1441
1403
  * ```js
1442
- * const http = require('http');
1404
+ * const http = require('node:http');
1443
1405
  *
1444
1406
  * const postData = JSON.stringify({
1445
- * 'msg': 'Hello World!'
1407
+ * 'msg': 'Hello World!',
1446
1408
  * });
1447
1409
  *
1448
1410
  * const options = {
@@ -1452,8 +1414,8 @@ declare module 'http' {
1452
1414
  * method: 'POST',
1453
1415
  * headers: {
1454
1416
  * 'Content-Type': 'application/json',
1455
- * 'Content-Length': Buffer.byteLength(postData)
1456
- * }
1417
+ * 'Content-Length': Buffer.byteLength(postData),
1418
+ * },
1457
1419
  * };
1458
1420
  *
1459
1421
  * const req = http.request(options, (res) => {
@@ -1540,7 +1502,7 @@ declare module 'http' {
1540
1502
  * * `'data'` any number of times, on the `res` object
1541
1503
  * * (connection closed here)
1542
1504
  * * `'aborted'` on the `res` object
1543
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1505
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
1544
1506
  * * `'close'`
1545
1507
  * * `'close'` on the `res` object
1546
1508
  *
@@ -1548,7 +1510,7 @@ declare module 'http' {
1548
1510
  * events will be emitted in the following order:
1549
1511
  *
1550
1512
  * * (`req.destroy()` called here)
1551
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1513
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1552
1514
  * * `'close'`
1553
1515
  *
1554
1516
  * If `req.destroy()` is called before the connection succeeds, the following
@@ -1556,7 +1518,7 @@ declare module 'http' {
1556
1518
  *
1557
1519
  * * `'socket'`
1558
1520
  * * (`req.destroy()` called here)
1559
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1521
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1560
1522
  * * `'close'`
1561
1523
  *
1562
1524
  * If `req.destroy()` is called after the response is received, the following
@@ -1567,7 +1529,7 @@ declare module 'http' {
1567
1529
  * * `'data'` any number of times, on the `res` object
1568
1530
  * * (`req.destroy()` called here)
1569
1531
  * * `'aborted'` on the `res` object
1570
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1532
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1571
1533
  * * `'close'`
1572
1534
  * * `'close'` on the `res` object
1573
1535
  *
@@ -1603,16 +1565,13 @@ declare module 'http' {
1603
1565
  * Setting the `timeout` option or using the `setTimeout()` function will
1604
1566
  * not abort the request or do anything besides add a `'timeout'` event.
1605
1567
  *
1606
- * Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1607
- * request itself.
1568
+ * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1569
+ * request. Specifically, the `'error'` event will be emitted with an error with
1570
+ * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided.
1608
1571
  * @since v0.3.6
1609
1572
  */
1610
1573
  function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1611
- function request(
1612
- url: string | URL,
1613
- options: RequestOptions,
1614
- callback?: (res: IncomingMessage) => void,
1615
- ): ClientRequest;
1574
+ function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1616
1575
  /**
1617
1576
  * Since most requests are GET requests without bodies, Node.js provides this
1618
1577
  * convenience method. The only difference between this method and {@link request} is that it sets the method to GET and calls `req.end()`automatically. The callback must take care to consume the
@@ -1664,7 +1623,7 @@ declare module 'http' {
1664
1623
  * const server = http.createServer((req, res) => {
1665
1624
  * res.writeHead(200, { 'Content-Type': 'application/json' });
1666
1625
  * res.end(JSON.stringify({
1667
- * data: 'Hello World!'
1626
+ * data: 'Hello World!',
1668
1627
  * }));
1669
1628
  * });
1670
1629
  *
@@ -1675,32 +1634,76 @@ declare module 'http' {
1675
1634
  */
1676
1635
  function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1677
1636
  function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1678
-
1679
1637
  /**
1680
- * Performs the low-level validations on the provided name that are done when `res.setHeader(name, value)` is called.
1681
- * Passing illegal value as name will result in a TypeError being thrown, identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1682
- * @param name Header name
1638
+ * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called.
1639
+ *
1640
+ * Passing illegal value as `name` will result in a `TypeError` being thrown,
1641
+ * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1642
+ *
1643
+ * It is not necessary to use this method before passing headers to an HTTP request
1644
+ * or response. The HTTP module will automatically validate such headers.
1645
+ * Examples:
1646
+ *
1647
+ * Example:
1648
+ *
1649
+ * ```js
1650
+ * const { validateHeaderName } = require('node:http');
1651
+ *
1652
+ * try {
1653
+ * validateHeaderName('');
1654
+ * } catch (err) {
1655
+ * console.error(err instanceof TypeError); // --> true
1656
+ * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
1657
+ * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
1658
+ * }
1659
+ * ```
1683
1660
  * @since v14.3.0
1661
+ * @param [label='Header name'] Label for error message.
1684
1662
  */
1685
1663
  function validateHeaderName(name: string): void;
1686
1664
  /**
1687
- * Performs the low-level validations on the provided value that are done when `res.setHeader(name, value)` is called.
1688
- * Passing illegal value as value will result in a TypeError being thrown.
1689
- * - Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1690
- * - Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1665
+ * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called.
1666
+ *
1667
+ * Passing illegal value as `value` will result in a `TypeError` being thrown.
1668
+ *
1669
+ * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1670
+ * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1671
+ *
1672
+ * It is not necessary to use this method before passing headers to an HTTP request
1673
+ * or response. The HTTP module will automatically validate such headers.
1674
+ *
1675
+ * Examples:
1676
+ *
1677
+ * ```js
1678
+ * const { validateHeaderValue } = require('node:http');
1679
+ *
1680
+ * try {
1681
+ * validateHeaderValue('x-my-header', undefined);
1682
+ * } catch (err) {
1683
+ * console.error(err instanceof TypeError); // --> true
1684
+ * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
1685
+ * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
1686
+ * }
1687
+ *
1688
+ * try {
1689
+ * validateHeaderValue('x-my-header', 'oʊmɪɡə');
1690
+ * } catch (err) {
1691
+ * console.error(err instanceof TypeError); // --> true
1692
+ * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
1693
+ * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
1694
+ * }
1695
+ * ```
1696
+ * @since v14.3.0
1691
1697
  * @param name Header name
1692
1698
  * @param value Header value
1693
- * @since v14.3.0
1694
1699
  */
1695
1700
  function validateHeaderValue(name: string, value: string): void;
1696
-
1697
1701
  /**
1698
- * Set the maximum number of idle HTTP parsers. Default: 1000.
1699
- * @param count
1702
+ * Set the maximum number of idle HTTP parsers.
1700
1703
  * @since v18.8.0, v16.18.0
1704
+ * @param [max=1000]
1701
1705
  */
1702
- function setMaxIdleHTTPParsers(count: number): void;
1703
-
1706
+ function setMaxIdleHTTPParsers(max: number): void;
1704
1707
  let globalAgent: Agent;
1705
1708
  /**
1706
1709
  * Read-only property specifying the maximum allowed size of HTTP headers in bytes.