@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/ts4.8/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';
@@ -322,7 +322,8 @@ declare module 'http' {
322
322
  */
323
323
  closeAllConnections(): void;
324
324
  /**
325
- * Closes all connections connected to this server which are not sending a request or waiting for a response.
325
+ * Closes all connections connected to this server which are not sending a request
326
+ * or waiting for a response.
326
327
  * @since v18.2.0
327
328
  */
328
329
  closeIdleConnections(): void;
@@ -334,15 +335,9 @@ declare module 'http' {
334
335
  addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
335
336
  addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
336
337
  addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
337
- addListener(
338
- event: 'connect',
339
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
340
- ): this;
338
+ addListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
341
339
  addListener(event: 'request', listener: RequestListener<Request, Response>): this;
342
- addListener(
343
- event: 'upgrade',
344
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
345
- ): this;
340
+ addListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
346
341
  emit(event: string, ...args: any[]): boolean;
347
342
  emit(event: 'close'): boolean;
348
343
  emit(event: 'connection', socket: Socket): boolean;
@@ -385,15 +380,9 @@ declare module 'http' {
385
380
  once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
386
381
  once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
387
382
  once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
388
- once(
389
- event: 'connect',
390
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
391
- ): this;
383
+ once(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
392
384
  once(event: 'request', listener: RequestListener<Request, Response>): this;
393
- once(
394
- event: 'upgrade',
395
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
396
- ): this;
385
+ once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
397
386
  prependListener(event: string, listener: (...args: any[]) => void): this;
398
387
  prependListener(event: 'close', listener: () => void): this;
399
388
  prependListener(event: 'connection', listener: (socket: Socket) => void): this;
@@ -402,15 +391,9 @@ declare module 'http' {
402
391
  prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
403
392
  prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
404
393
  prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
405
- prependListener(
406
- event: 'connect',
407
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
408
- ): this;
394
+ prependListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
409
395
  prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
410
- prependListener(
411
- event: 'upgrade',
412
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
413
- ): this;
396
+ prependListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
414
397
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
415
398
  prependOnceListener(event: 'close', listener: () => void): this;
416
399
  prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
@@ -419,19 +402,13 @@ declare module 'http' {
419
402
  prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
420
403
  prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
421
404
  prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
422
- prependOnceListener(
423
- event: 'connect',
424
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
425
- ): this;
405
+ prependOnceListener(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
426
406
  prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
427
- prependOnceListener(
428
- event: 'upgrade',
429
- listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
430
- ): this;
407
+ prependOnceListener(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
431
408
  }
432
409
  /**
433
- * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from
434
- * the perspective of the participants of HTTP transaction.
410
+ * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
411
+ * the perspective of the participants of an HTTP transaction.
435
412
  * @since v0.1.17
436
413
  */
437
414
  class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
@@ -450,7 +427,7 @@ declare module 'http' {
450
427
  */
451
428
  readonly headersSent: boolean;
452
429
  /**
453
- * Aliases of `outgoingMessage.socket`
430
+ * Alias of `outgoingMessage.socket`.
454
431
  * @since v0.3.0
455
432
  * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
456
433
  */
@@ -471,15 +448,17 @@ declare module 'http' {
471
448
  */
472
449
  setTimeout(msecs: number, callback?: () => void): this;
473
450
  /**
474
- * Sets a single header value for the header object.
451
+ * Sets a single header value. If the header already exists in the to-be-sent
452
+ * headers, its value will be replaced. Use an array of strings to send multiple
453
+ * headers with the same name.
475
454
  * @since v0.4.0
476
455
  * @param name Header name
477
456
  * @param value Header value
478
457
  */
479
458
  setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
480
459
  /**
481
- * Gets the value of HTTP header with the given name. If such a name doesn't
482
- * exist in message, it will be `undefined`.
460
+ * Gets the value of the HTTP header with the given name. If that header is not
461
+ * set, the returned value will be `undefined`.
483
462
  * @since v0.4.0
484
463
  * @param name Name of header
485
464
  */
@@ -492,8 +471,8 @@ declare module 'http' {
492
471
  * values. All header names are lowercase.
493
472
  *
494
473
  * The object returned by the `outgoingMessage.getHeaders()` method does
495
- * not prototypically inherit from the JavaScript Object. This means that
496
- * typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`,
474
+ * not prototypically inherit from the JavaScript `Object`. This means that
475
+ * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
497
476
  * and others are not defined and will not work.
498
477
  *
499
478
  * ```js
@@ -507,8 +486,8 @@ declare module 'http' {
507
486
  */
508
487
  getHeaders(): OutgoingHttpHeaders;
509
488
  /**
510
- * Returns an array of names of headers of the outgoing outgoingMessage. All
511
- * names are lowercase.
489
+ * Returns an array containing the unique names of the current outgoing headers.
490
+ * All names are lowercase.
512
491
  * @since v7.7.0
513
492
  */
514
493
  getHeaderNames(): string[];
@@ -535,11 +514,11 @@ declare module 'http' {
535
514
  /**
536
515
  * Adds HTTP trailers (headers but at the end of the message) to the message.
537
516
  *
538
- * Trailers are **only** be emitted if the message is chunked encoded. If not,
539
- * the trailer will be silently discarded.
517
+ * Trailers will **only** be emitted if the message is chunked encoded. If not,
518
+ * the trailers will be silently discarded.
540
519
  *
541
520
  * HTTP requires the `Trailer` header to be sent to emit trailers,
542
- * with a list of header fields in its value, e.g.
521
+ * with a list of header field names in its value, e.g.
543
522
  *
544
523
  * ```js
545
524
  * message.writeHead(200, { 'Content-Type': 'text/plain',
@@ -555,7 +534,7 @@ declare module 'http' {
555
534
  */
556
535
  addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
557
536
  /**
558
- * Compulsorily flushes the message headers
537
+ * Flushes the message headers.
559
538
  *
560
539
  * For efficiency reason, Node.js normally buffers the message headers
561
540
  * until `outgoingMessage.end()` is called or the first chunk of message data
@@ -563,7 +542,7 @@ declare module 'http' {
563
542
  * packet.
564
543
  *
565
544
  * It is usually desired (it saves a TCP round-trip), but not when the first
566
- * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request.
545
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
567
546
  * @since v1.6.0
568
547
  */
569
548
  flushHeaders(): void;
@@ -619,7 +598,7 @@ declare module 'http' {
619
598
  * early hints message. The optional `callback` argument will be called when
620
599
  * the response message has been written.
621
600
  *
622
- * Example:
601
+ * **Example**
623
602
  *
624
603
  * ```js
625
604
  * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
@@ -633,15 +612,14 @@ declare module 'http' {
633
612
  * ];
634
613
  * response.writeEarlyHints({
635
614
  * 'link': earlyHintsLinks,
636
- * 'x-trace-id': 'id for diagnostics'
615
+ * 'x-trace-id': 'id for diagnostics',
637
616
  * });
638
617
  *
639
618
  * const earlyHintsCallback = () => console.log('early hints message sent');
640
619
  * response.writeEarlyHints({
641
- * 'link': earlyHintsLinks
620
+ * 'link': earlyHintsLinks,
642
621
  * }, earlyHintsCallback);
643
622
  * ```
644
- *
645
623
  * @since v18.11.0
646
624
  * @param hints An object containing the values of headers
647
625
  * @param callback Will be called when the response message has been written
@@ -665,7 +643,7 @@ declare module 'http' {
665
643
  * response
666
644
  * .writeHead(200, {
667
645
  * 'Content-Length': Buffer.byteLength(body),
668
- * 'Content-Type': 'text/plain'
646
+ * 'Content-Type': 'text/plain',
669
647
  * })
670
648
  * .end(body);
671
649
  * ```
@@ -696,12 +674,12 @@ declare module 'http' {
696
674
  * });
697
675
  * ```
698
676
  *
699
- * `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
700
- * does not check whether `Content-Length` and the length of the body which has
677
+ * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
678
+ * will check whether `Content-Length` and the length of the body which has
701
679
  * been transmitted are equal or not.
702
680
  *
703
681
  * Attempting to set a header field name or value that contains invalid characters
704
- * will result in a `TypeError` being thrown.
682
+ * will result in a \[`Error`\]\[\] being thrown.
705
683
  * @since v0.1.30
706
684
  */
707
685
  writeHead(
@@ -711,7 +689,7 @@ declare module 'http' {
711
689
  ): this;
712
690
  writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
713
691
  /**
714
- * Sends an HTTP/1.1 102 Processing message to the client, indicating that
692
+ * Sends a HTTP/1.1 102 Processing message to the client, indicating that
715
693
  * the request body should be sent.
716
694
  * @since v10.0.0
717
695
  */
@@ -750,8 +728,11 @@ declare module 'http' {
750
728
  *
751
729
  * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
752
730
  *
753
- * Node.js does not check whether Content-Length and the length of the
754
- * body which has been transmitted are equal or not.
731
+ * Set `Content-Length` header to limit the response body size.
732
+ * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown,
733
+ * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
734
+ *
735
+ * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
755
736
  * @since v0.1.17
756
737
  */
757
738
  class ClientRequest extends OutgoingMessage {
@@ -778,7 +759,7 @@ declare module 'http' {
778
759
  * may run into a 'ECONNRESET' error.
779
760
  *
780
761
  * ```js
781
- * const http = require('http');
762
+ * const http = require('node:http');
782
763
  *
783
764
  * // Server has a 5 seconds keep-alive timeout by default
784
765
  * http
@@ -802,7 +783,7 @@ declare module 'http' {
802
783
  * automatic error retry base on it.
803
784
  *
804
785
  * ```js
805
- * const http = require('http');
786
+ * const http = require('node:http');
806
787
  * const agent = new http.Agent({ keepAlive: true });
807
788
  *
808
789
  * function retriableRequest() {
@@ -881,19 +862,13 @@ declare module 'http' {
881
862
  * @deprecated
882
863
  */
883
864
  addListener(event: 'abort', listener: () => void): this;
884
- addListener(
885
- event: 'connect',
886
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
887
- ): this;
865
+ addListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
888
866
  addListener(event: 'continue', listener: () => void): this;
889
867
  addListener(event: 'information', listener: (info: InformationEvent) => void): this;
890
868
  addListener(event: 'response', listener: (response: IncomingMessage) => void): this;
891
869
  addListener(event: 'socket', listener: (socket: Socket) => void): this;
892
870
  addListener(event: 'timeout', listener: () => void): this;
893
- addListener(
894
- event: 'upgrade',
895
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
896
- ): this;
871
+ addListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
897
872
  addListener(event: 'close', listener: () => void): this;
898
873
  addListener(event: 'drain', listener: () => void): this;
899
874
  addListener(event: 'error', listener: (err: Error) => void): this;
@@ -941,19 +916,13 @@ declare module 'http' {
941
916
  * @deprecated
942
917
  */
943
918
  prependListener(event: 'abort', listener: () => void): this;
944
- prependListener(
945
- event: 'connect',
946
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
947
- ): this;
919
+ prependListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
948
920
  prependListener(event: 'continue', listener: () => void): this;
949
921
  prependListener(event: 'information', listener: (info: InformationEvent) => void): this;
950
922
  prependListener(event: 'response', listener: (response: IncomingMessage) => void): this;
951
923
  prependListener(event: 'socket', listener: (socket: Socket) => void): this;
952
924
  prependListener(event: 'timeout', listener: () => void): this;
953
- prependListener(
954
- event: 'upgrade',
955
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
956
- ): this;
925
+ prependListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
957
926
  prependListener(event: 'close', listener: () => void): this;
958
927
  prependListener(event: 'drain', listener: () => void): this;
959
928
  prependListener(event: 'error', listener: (err: Error) => void): this;
@@ -965,19 +934,13 @@ declare module 'http' {
965
934
  * @deprecated
966
935
  */
967
936
  prependOnceListener(event: 'abort', listener: () => void): this;
968
- prependOnceListener(
969
- event: 'connect',
970
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
971
- ): this;
937
+ prependOnceListener(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
972
938
  prependOnceListener(event: 'continue', listener: () => void): this;
973
939
  prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this;
974
940
  prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this;
975
941
  prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this;
976
942
  prependOnceListener(event: 'timeout', listener: () => void): this;
977
- prependOnceListener(
978
- event: 'upgrade',
979
- listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
980
- ): this;
943
+ prependOnceListener(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
981
944
  prependOnceListener(event: 'close', listener: () => void): this;
982
945
  prependOnceListener(event: 'drain', listener: () => void): this;
983
946
  prependOnceListener(event: 'error', listener: (err: Error) => void): this;
@@ -989,7 +952,7 @@ declare module 'http' {
989
952
  /**
990
953
  * 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
991
954
  * access response
992
- * status, headers and data.
955
+ * status, headers, and data.
993
956
  *
994
957
  * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
995
958
  * parse and emit the incoming HTTP headers and payload, as the underlying socket
@@ -1027,7 +990,7 @@ declare module 'http' {
1027
990
  * const req = http.request({
1028
991
  * host: '127.0.0.1',
1029
992
  * port: 8080,
1030
- * method: 'POST'
993
+ * method: 'POST',
1031
994
  * }, (res) => {
1032
995
  * res.resume();
1033
996
  * res.on('end', () => {
@@ -1069,7 +1032,7 @@ declare module 'http' {
1069
1032
  * // { 'user-agent': 'curl/7.22.0',
1070
1033
  * // host: '127.0.0.1:8000',
1071
1034
  * // accept: '*' }
1072
- * console.log(request.getHeaders());
1035
+ * console.log(request.headers);
1073
1036
  * ```
1074
1037
  *
1075
1038
  * Duplicates in raw headers are handled in the following ways, depending on the
@@ -1077,9 +1040,12 @@ declare module 'http' {
1077
1040
  *
1078
1041
  * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
1079
1042
  * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
1043
+ * To allow duplicate values of the headers listed above to be joined,
1044
+ * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
1045
+ * information.
1080
1046
  * * `set-cookie` is always an array. Duplicates are added to the array.
1081
- * * For duplicate `cookie` headers, the values are joined together with '; '.
1082
- * * For all other headers, the values are joined together with ', '.
1047
+ * * For duplicate `cookie` headers, the values are joined together with `; `.
1048
+ * * For all other headers, the values are joined together with `, `.
1083
1049
  * @since v0.1.5
1084
1050
  */
1085
1051
  headers: IncomingHttpHeaders;
@@ -1145,14 +1111,14 @@ declare module 'http' {
1145
1111
  * To parse the URL into its parts:
1146
1112
  *
1147
1113
  * ```js
1148
- * new URL(request.url, `http://${request.getHeaders().host}`);
1114
+ * new URL(request.url, `http://${request.headers.host}`);
1149
1115
  * ```
1150
1116
  *
1151
- * When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
1117
+ * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
1152
1118
  *
1153
1119
  * ```console
1154
1120
  * $ node
1155
- * > new URL(request.url, `http://${request.getHeaders().host}`)
1121
+ * > new URL(request.url, `http://${request.headers.host}`)
1156
1122
  * URL {
1157
1123
  * href: 'http://localhost:3000/status?name=ryan',
1158
1124
  * origin: 'http://localhost:3000',
@@ -1272,7 +1238,7 @@ declare module 'http' {
1272
1238
  * hostname: 'localhost',
1273
1239
  * port: 80,
1274
1240
  * path: '/',
1275
- * agent: false // Create a new agent just for this one request
1241
+ * agent: false, // Create a new agent just for this one request
1276
1242
  * }, (res) => {
1277
1243
  * // Do stuff with response
1278
1244
  * });
@@ -1377,10 +1343,10 @@ declare module 'http' {
1377
1343
  * upload a file with a POST request, then write to the `ClientRequest` object.
1378
1344
  *
1379
1345
  * ```js
1380
- * const http = require('http');
1346
+ * const http = require('node:http');
1381
1347
  *
1382
1348
  * const postData = JSON.stringify({
1383
- * 'msg': 'Hello World!'
1349
+ * 'msg': 'Hello World!',
1384
1350
  * });
1385
1351
  *
1386
1352
  * const options = {
@@ -1390,8 +1356,8 @@ declare module 'http' {
1390
1356
  * method: 'POST',
1391
1357
  * headers: {
1392
1358
  * 'Content-Type': 'application/json',
1393
- * 'Content-Length': Buffer.byteLength(postData)
1394
- * }
1359
+ * 'Content-Length': Buffer.byteLength(postData),
1360
+ * },
1395
1361
  * };
1396
1362
  *
1397
1363
  * const req = http.request(options, (res) => {
@@ -1478,7 +1444,7 @@ declare module 'http' {
1478
1444
  * * `'data'` any number of times, on the `res` object
1479
1445
  * * (connection closed here)
1480
1446
  * * `'aborted'` on the `res` object
1481
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1447
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
1482
1448
  * * `'close'`
1483
1449
  * * `'close'` on the `res` object
1484
1450
  *
@@ -1486,7 +1452,7 @@ declare module 'http' {
1486
1452
  * events will be emitted in the following order:
1487
1453
  *
1488
1454
  * * (`req.destroy()` called here)
1489
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1455
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1490
1456
  * * `'close'`
1491
1457
  *
1492
1458
  * If `req.destroy()` is called before the connection succeeds, the following
@@ -1494,7 +1460,7 @@ declare module 'http' {
1494
1460
  *
1495
1461
  * * `'socket'`
1496
1462
  * * (`req.destroy()` called here)
1497
- * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1463
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1498
1464
  * * `'close'`
1499
1465
  *
1500
1466
  * If `req.destroy()` is called after the response is received, the following
@@ -1505,7 +1471,7 @@ declare module 'http' {
1505
1471
  * * `'data'` any number of times, on the `res` object
1506
1472
  * * (`req.destroy()` called here)
1507
1473
  * * `'aborted'` on the `res` object
1508
- * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1474
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1509
1475
  * * `'close'`
1510
1476
  * * `'close'` on the `res` object
1511
1477
  *
@@ -1541,16 +1507,13 @@ declare module 'http' {
1541
1507
  * Setting the `timeout` option or using the `setTimeout()` function will
1542
1508
  * not abort the request or do anything besides add a `'timeout'` event.
1543
1509
  *
1544
- * Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1545
- * request itself.
1510
+ * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1511
+ * request. Specifically, the `'error'` event will be emitted with an error with
1512
+ * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided.
1546
1513
  * @since v0.3.6
1547
1514
  */
1548
1515
  function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1549
- function request(
1550
- url: string | URL,
1551
- options: RequestOptions,
1552
- callback?: (res: IncomingMessage) => void,
1553
- ): ClientRequest;
1516
+ function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1554
1517
  /**
1555
1518
  * Since most requests are GET requests without bodies, Node.js provides this
1556
1519
  * 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
@@ -1602,7 +1565,7 @@ declare module 'http' {
1602
1565
  * const server = http.createServer((req, res) => {
1603
1566
  * res.writeHead(200, { 'Content-Type': 'application/json' });
1604
1567
  * res.end(JSON.stringify({
1605
- * data: 'Hello World!'
1568
+ * data: 'Hello World!',
1606
1569
  * }));
1607
1570
  * });
1608
1571
  *
@@ -1613,32 +1576,76 @@ declare module 'http' {
1613
1576
  */
1614
1577
  function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1615
1578
  function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1616
-
1617
1579
  /**
1618
- * Performs the low-level validations on the provided name that are done when `res.setHeader(name, value)` is called.
1619
- * Passing illegal value as name will result in a TypeError being thrown, identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1620
- * @param name Header name
1580
+ * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called.
1581
+ *
1582
+ * Passing illegal value as `name` will result in a `TypeError` being thrown,
1583
+ * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1584
+ *
1585
+ * It is not necessary to use this method before passing headers to an HTTP request
1586
+ * or response. The HTTP module will automatically validate such headers.
1587
+ * Examples:
1588
+ *
1589
+ * Example:
1590
+ *
1591
+ * ```js
1592
+ * const { validateHeaderName } = require('node:http');
1593
+ *
1594
+ * try {
1595
+ * validateHeaderName('');
1596
+ * } catch (err) {
1597
+ * console.error(err instanceof TypeError); // --> true
1598
+ * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
1599
+ * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
1600
+ * }
1601
+ * ```
1621
1602
  * @since v14.3.0
1603
+ * @param [name='Header name'] Label for error message.
1622
1604
  */
1623
1605
  function validateHeaderName(name: string): void;
1624
1606
  /**
1625
- * Performs the low-level validations on the provided value that are done when `res.setHeader(name, value)` is called.
1626
- * Passing illegal value as value will result in a TypeError being thrown.
1627
- * - Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1628
- * - Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1607
+ * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called.
1608
+ *
1609
+ * Passing illegal value as `value` will result in a `TypeError` being thrown.
1610
+ *
1611
+ * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1612
+ * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1613
+ *
1614
+ * It is not necessary to use this method before passing headers to an HTTP request
1615
+ * or response. The HTTP module will automatically validate such headers.
1616
+ *
1617
+ * Examples:
1618
+ *
1619
+ * ```js
1620
+ * const { validateHeaderValue } = require('node:http');
1621
+ *
1622
+ * try {
1623
+ * validateHeaderValue('x-my-header', undefined);
1624
+ * } catch (err) {
1625
+ * console.error(err instanceof TypeError); // --> true
1626
+ * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
1627
+ * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
1628
+ * }
1629
+ *
1630
+ * try {
1631
+ * validateHeaderValue('x-my-header', 'oʊmɪɡə');
1632
+ * } catch (err) {
1633
+ * console.error(err instanceof TypeError); // --> true
1634
+ * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
1635
+ * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
1636
+ * }
1637
+ * ```
1638
+ * @since v14.3.0
1629
1639
  * @param name Header name
1630
1640
  * @param value Header value
1631
- * @since v14.3.0
1632
1641
  */
1633
1642
  function validateHeaderValue(name: string, value: string): void;
1634
-
1635
1643
  /**
1636
- * Set the maximum number of idle HTTP parsers. Default: 1000.
1637
- * @param count
1644
+ * Set the maximum number of idle HTTP parsers.
1638
1645
  * @since v18.8.0, v16.18.0
1646
+ * @param [max=1000]
1639
1647
  */
1640
- function setMaxIdleHTTPParsers(count: number): void;
1641
-
1648
+ function setMaxIdleHTTPParsers(max: number): void;
1642
1649
  let globalAgent: Agent;
1643
1650
  /**
1644
1651
  * Read-only property specifying the maximum allowed size of HTTP headers in bytes.