@rio-cloud/cdk-v2-constructs 8.2.0-alpha.0 → 8.2.1-alpha.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 (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
@@ -3,12 +3,13 @@
3
3
  * It can be accessed using:
4
4
  *
5
5
  * ```js
6
- * const http2 = require('node:http2');
6
+ * import http2 from 'node:http2';
7
7
  * ```
8
8
  * @since v8.4.0
9
- * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/http2.js)
10
10
  */
11
11
  declare module "http2" {
12
+ import { NonSharedBuffer } from "node:buffer";
12
13
  import EventEmitter = require("node:events");
13
14
  import * as fs from "node:fs";
14
15
  import * as net from "node:net";
@@ -30,20 +31,17 @@ declare module "http2" {
30
31
  ":method"?: string | undefined;
31
32
  ":authority"?: string | undefined;
32
33
  ":scheme"?: string | undefined;
34
+ ":protocol"?: string | undefined;
33
35
  }
34
36
  // Http2Stream
35
- export interface StreamPriorityOptions {
36
- exclusive?: boolean | undefined;
37
- parent?: number | undefined;
38
- weight?: number | undefined;
39
- silent?: boolean | undefined;
40
- }
41
37
  export interface StreamState {
42
38
  localWindowSize?: number | undefined;
43
39
  state?: number | undefined;
44
40
  localClose?: number | undefined;
45
41
  remoteClose?: number | undefined;
42
+ /** @deprecated */
46
43
  sumDependencyWeight?: number | undefined;
44
+ /** @deprecated */
47
45
  weight?: number | undefined;
48
46
  }
49
47
  export interface ServerStreamResponseOptions {
@@ -55,14 +53,15 @@ declare module "http2" {
55
53
  length: number;
56
54
  }
57
55
  export interface ServerStreamFileResponseOptions {
58
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
59
- statCheck?(stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions): void | boolean;
56
+ statCheck?:
57
+ | ((stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void)
58
+ | undefined;
60
59
  waitForTrailers?: boolean | undefined;
61
60
  offset?: number | undefined;
62
61
  length?: number | undefined;
63
62
  }
64
63
  export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
65
- onError?(err: NodeJS.ErrnoException): void;
64
+ onError?: ((err: NodeJS.ErrnoException) => void) | undefined;
66
65
  }
67
66
  export interface Http2Stream extends stream.Duplex {
68
67
  /**
@@ -96,7 +95,7 @@ declare module "http2" {
96
95
  */
97
96
  readonly endAfterHeaders: boolean;
98
97
  /**
99
- * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined`if the stream identifier has not yet been assigned.
98
+ * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined` if the stream identifier has not yet been assigned.
100
99
  * @since v8.4.0
101
100
  */
102
101
  readonly id?: number | undefined;
@@ -109,7 +108,7 @@ declare module "http2" {
109
108
  /**
110
109
  * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is
111
110
  * destroyed after either receiving an `RST_STREAM` frame from the connected peer,
112
- * calling `http2stream.close()`, or `http2stream.destroy()`. Will be`undefined` if the `Http2Stream` has not been closed.
111
+ * calling `http2stream.close()`, or `http2stream.destroy()`. Will be `undefined` if the `Http2Stream` has not been closed.
113
112
  * @since v8.4.0
114
113
  */
115
114
  readonly rstCode: number;
@@ -136,7 +135,7 @@ declare module "http2" {
136
135
  */
137
136
  readonly session: Http2Session | undefined;
138
137
  /**
139
- * Provides miscellaneous information about the current state of the`Http2Stream`.
138
+ * Provides miscellaneous information about the current state of the `Http2Stream`.
140
139
  *
141
140
  * A current state of this `Http2Stream`.
142
141
  * @since v8.4.0
@@ -151,13 +150,12 @@ declare module "http2" {
151
150
  */
152
151
  close(code?: number, callback?: () => void): void;
153
152
  /**
154
- * Updates the priority for this `Http2Stream` instance.
155
- * @since v8.4.0
153
+ * @deprecated Priority signaling is no longer supported in Node.js.
156
154
  */
157
- priority(options: StreamPriorityOptions): void;
155
+ priority(options: unknown): void;
158
156
  /**
159
157
  * ```js
160
- * const http2 = require('node:http2');
158
+ * import http2 from 'node:http2';
161
159
  * const client = http2.connect('http://example.org:8000');
162
160
  * const { NGHTTP2_CANCEL } = http2.constants;
163
161
  * const req = client.request({ ':path': '/' });
@@ -177,7 +175,7 @@ declare module "http2" {
177
175
  * trailers can be sent.
178
176
  *
179
177
  * ```js
180
- * const http2 = require('node:http2');
178
+ * import http2 from 'node:http2';
181
179
  * const server = http2.createServer();
182
180
  * server.on('stream', (stream) => {
183
181
  * stream.respond(undefined, { waitForTrailers: true });
@@ -195,12 +193,15 @@ declare module "http2" {
195
193
  sendTrailers(headers: OutgoingHttpHeaders): void;
196
194
  addListener(event: "aborted", listener: () => void): this;
197
195
  addListener(event: "close", listener: () => void): this;
198
- addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
196
+ addListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
199
197
  addListener(event: "drain", listener: () => void): this;
200
198
  addListener(event: "end", listener: () => void): this;
201
199
  addListener(event: "error", listener: (err: Error) => void): this;
202
200
  addListener(event: "finish", listener: () => void): this;
203
- addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
201
+ addListener(
202
+ event: "frameError",
203
+ listener: (frameType: number, errorCode: number, id: number) => void,
204
+ ): this;
204
205
  addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
205
206
  addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
206
207
  addListener(event: "streamClosed", listener: (code: number) => void): this;
@@ -210,12 +211,12 @@ declare module "http2" {
210
211
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
211
212
  emit(event: "aborted"): boolean;
212
213
  emit(event: "close"): boolean;
213
- emit(event: "data", chunk: Buffer | string): boolean;
214
+ emit(event: "data", chunk: NonSharedBuffer | string): boolean;
214
215
  emit(event: "drain"): boolean;
215
216
  emit(event: "end"): boolean;
216
217
  emit(event: "error", err: Error): boolean;
217
218
  emit(event: "finish"): boolean;
218
- emit(event: "frameError", frameType: number, errorCode: number): boolean;
219
+ emit(event: "frameError", frameType: number, errorCode: number, id: number): boolean;
219
220
  emit(event: "pipe", src: stream.Readable): boolean;
220
221
  emit(event: "unpipe", src: stream.Readable): boolean;
221
222
  emit(event: "streamClosed", code: number): boolean;
@@ -225,12 +226,12 @@ declare module "http2" {
225
226
  emit(event: string | symbol, ...args: any[]): boolean;
226
227
  on(event: "aborted", listener: () => void): this;
227
228
  on(event: "close", listener: () => void): this;
228
- on(event: "data", listener: (chunk: Buffer | string) => void): this;
229
+ on(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
229
230
  on(event: "drain", listener: () => void): this;
230
231
  on(event: "end", listener: () => void): this;
231
232
  on(event: "error", listener: (err: Error) => void): this;
232
233
  on(event: "finish", listener: () => void): this;
233
- on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
234
+ on(event: "frameError", listener: (frameType: number, errorCode: number, id: number) => void): this;
234
235
  on(event: "pipe", listener: (src: stream.Readable) => void): this;
235
236
  on(event: "unpipe", listener: (src: stream.Readable) => void): this;
236
237
  on(event: "streamClosed", listener: (code: number) => void): this;
@@ -240,12 +241,12 @@ declare module "http2" {
240
241
  on(event: string | symbol, listener: (...args: any[]) => void): this;
241
242
  once(event: "aborted", listener: () => void): this;
242
243
  once(event: "close", listener: () => void): this;
243
- once(event: "data", listener: (chunk: Buffer | string) => void): this;
244
+ once(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
244
245
  once(event: "drain", listener: () => void): this;
245
246
  once(event: "end", listener: () => void): this;
246
247
  once(event: "error", listener: (err: Error) => void): this;
247
248
  once(event: "finish", listener: () => void): this;
248
- once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
249
+ once(event: "frameError", listener: (frameType: number, errorCode: number, id: number) => void): this;
249
250
  once(event: "pipe", listener: (src: stream.Readable) => void): this;
250
251
  once(event: "unpipe", listener: (src: stream.Readable) => void): this;
251
252
  once(event: "streamClosed", listener: (code: number) => void): this;
@@ -255,12 +256,15 @@ declare module "http2" {
255
256
  once(event: string | symbol, listener: (...args: any[]) => void): this;
256
257
  prependListener(event: "aborted", listener: () => void): this;
257
258
  prependListener(event: "close", listener: () => void): this;
258
- prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
259
+ prependListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
259
260
  prependListener(event: "drain", listener: () => void): this;
260
261
  prependListener(event: "end", listener: () => void): this;
261
262
  prependListener(event: "error", listener: (err: Error) => void): this;
262
263
  prependListener(event: "finish", listener: () => void): this;
263
- prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
264
+ prependListener(
265
+ event: "frameError",
266
+ listener: (frameType: number, errorCode: number, id: number) => void,
267
+ ): this;
264
268
  prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
265
269
  prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
266
270
  prependListener(event: "streamClosed", listener: (code: number) => void): this;
@@ -270,12 +274,15 @@ declare module "http2" {
270
274
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
271
275
  prependOnceListener(event: "aborted", listener: () => void): this;
272
276
  prependOnceListener(event: "close", listener: () => void): this;
273
- prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
277
+ prependOnceListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
274
278
  prependOnceListener(event: "drain", listener: () => void): this;
275
279
  prependOnceListener(event: "end", listener: () => void): this;
276
280
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
277
281
  prependOnceListener(event: "finish", listener: () => void): this;
278
- prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
282
+ prependOnceListener(
283
+ event: "frameError",
284
+ listener: (frameType: number, errorCode: number, id: number) => void,
285
+ ): this;
279
286
  prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
280
287
  prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
281
288
  prependOnceListener(event: "streamClosed", listener: (code: number) => void): this;
@@ -288,61 +295,111 @@ declare module "http2" {
288
295
  addListener(event: "continue", listener: () => {}): this;
289
296
  addListener(
290
297
  event: "headers",
291
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
298
+ listener: (
299
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
300
+ flags: number,
301
+ rawHeaders: string[],
302
+ ) => void,
292
303
  ): this;
293
304
  addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
294
305
  addListener(
295
306
  event: "response",
296
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
307
+ listener: (
308
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
309
+ flags: number,
310
+ rawHeaders: string[],
311
+ ) => void,
297
312
  ): this;
298
313
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
299
314
  emit(event: "continue"): boolean;
300
- emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
315
+ emit(
316
+ event: "headers",
317
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
318
+ flags: number,
319
+ rawHeaders: string[],
320
+ ): boolean;
301
321
  emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean;
302
- emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
322
+ emit(
323
+ event: "response",
324
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
325
+ flags: number,
326
+ rawHeaders: string[],
327
+ ): boolean;
303
328
  emit(event: string | symbol, ...args: any[]): boolean;
304
329
  on(event: "continue", listener: () => {}): this;
305
330
  on(
306
331
  event: "headers",
307
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
332
+ listener: (
333
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
334
+ flags: number,
335
+ rawHeaders: string[],
336
+ ) => void,
308
337
  ): this;
309
338
  on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
310
339
  on(
311
340
  event: "response",
312
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
341
+ listener: (
342
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
343
+ flags: number,
344
+ rawHeaders: string[],
345
+ ) => void,
313
346
  ): this;
314
347
  on(event: string | symbol, listener: (...args: any[]) => void): this;
315
348
  once(event: "continue", listener: () => {}): this;
316
349
  once(
317
350
  event: "headers",
318
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
351
+ listener: (
352
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
353
+ flags: number,
354
+ rawHeaders: string[],
355
+ ) => void,
319
356
  ): this;
320
357
  once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
321
358
  once(
322
359
  event: "response",
323
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
360
+ listener: (
361
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
362
+ flags: number,
363
+ rawHeaders: string[],
364
+ ) => void,
324
365
  ): this;
325
366
  once(event: string | symbol, listener: (...args: any[]) => void): this;
326
367
  prependListener(event: "continue", listener: () => {}): this;
327
368
  prependListener(
328
369
  event: "headers",
329
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
370
+ listener: (
371
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
372
+ flags: number,
373
+ rawHeaders: string[],
374
+ ) => void,
330
375
  ): this;
331
376
  prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
332
377
  prependListener(
333
378
  event: "response",
334
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
379
+ listener: (
380
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
381
+ flags: number,
382
+ rawHeaders: string[],
383
+ ) => void,
335
384
  ): this;
336
385
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
337
386
  prependOnceListener(event: "continue", listener: () => {}): this;
338
387
  prependOnceListener(
339
388
  event: "headers",
340
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
389
+ listener: (
390
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
391
+ flags: number,
392
+ rawHeaders: string[],
393
+ ) => void,
341
394
  ): this;
342
395
  prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
343
396
  prependOnceListener(
344
397
  event: "response",
345
- listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
398
+ listener: (
399
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
400
+ flags: number,
401
+ rawHeaders: string[],
402
+ ) => void,
346
403
  ): this;
347
404
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
348
405
  }
@@ -355,7 +412,7 @@ declare module "http2" {
355
412
  /**
356
413
  * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote
357
414
  * client's most recent `SETTINGS` frame. Will be `true` if the remote peer
358
- * accepts push streams, `false` otherwise. Settings are the same for every`Http2Stream` in the same `Http2Session`.
415
+ * accepts push streams, `false` otherwise. Settings are the same for every `Http2Stream` in the same `Http2Session`.
359
416
  * @since v8.4.0
360
417
  */
361
418
  readonly pushAllowed: boolean;
@@ -365,10 +422,10 @@ declare module "http2" {
365
422
  */
366
423
  additionalHeaders(headers: OutgoingHttpHeaders): void;
367
424
  /**
368
- * Initiates a push stream. The callback is invoked with the new `Http2Stream`instance created for the push stream passed as the second argument, or an`Error` passed as the first argument.
425
+ * Initiates a push stream. The callback is invoked with the new `Http2Stream` instance created for the push stream passed as the second argument, or an `Error` passed as the first argument.
369
426
  *
370
427
  * ```js
371
- * const http2 = require('node:http2');
428
+ * import http2 from 'node:http2';
372
429
  * const server = http2.createServer();
373
430
  * server.on('stream', (stream) => {
374
431
  * stream.respond({ ':status': 200 });
@@ -382,7 +439,7 @@ declare module "http2" {
382
439
  * ```
383
440
  *
384
441
  * Setting the weight of a push stream is not allowed in the `HEADERS` frame. Pass
385
- * a `weight` value to `http2stream.priority` with the `silent` option set to`true` to enable server-side bandwidth balancing between concurrent streams.
442
+ * a `weight` value to `http2stream.priority` with the `silent` option set to `true` to enable server-side bandwidth balancing between concurrent streams.
386
443
  *
387
444
  * Calling `http2stream.pushStream()` from within a pushed stream is not permitted
388
445
  * and will throw an error.
@@ -395,12 +452,12 @@ declare module "http2" {
395
452
  ): void;
396
453
  pushStream(
397
454
  headers: OutgoingHttpHeaders,
398
- options?: StreamPriorityOptions,
455
+ options?: Pick<ClientSessionRequestOptions, "exclusive" | "parent">,
399
456
  callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void,
400
457
  ): void;
401
458
  /**
402
459
  * ```js
403
- * const http2 = require('node:http2');
460
+ * import http2 from 'node:http2';
404
461
  * const server = http2.createServer();
405
462
  * server.on('stream', (stream) => {
406
463
  * stream.respond({ ':status': 200 });
@@ -408,15 +465,15 @@ declare module "http2" {
408
465
  * });
409
466
  * ```
410
467
  *
411
- * Initiates a response. When the `options.waitForTrailers` option is set, the`'wantTrailers'` event will be emitted immediately after queuing the last chunk
412
- * of payload data to be sent. The `http2stream.sendTrailers()` method can then be
413
- * used to sent trailing header fields to the peer.
468
+ * Initiates a response. When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
469
+ * will be emitted immediately after queuing the last chunk of payload data to be sent.
470
+ * The `http2stream.sendTrailers()` method can then be used to send trailing header fields to the peer.
414
471
  *
415
472
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
416
- * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
473
+ * close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.
417
474
  *
418
475
  * ```js
419
- * const http2 = require('node:http2');
476
+ * import http2 from 'node:http2';
420
477
  * const server = http2.createServer();
421
478
  * server.on('stream', (stream) => {
422
479
  * stream.respond({ ':status': 200 }, { waitForTrailers: true });
@@ -428,7 +485,7 @@ declare module "http2" {
428
485
  * ```
429
486
  * @since v8.4.0
430
487
  */
431
- respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
488
+ respond(headers?: OutgoingHttpHeaders | readonly string[], options?: ServerStreamResponseOptions): void;
432
489
  /**
433
490
  * Initiates a response whose data is read from the given file descriptor. No
434
491
  * validation is performed on the given file descriptor. If an error occurs while
@@ -439,8 +496,8 @@ declare module "http2" {
439
496
  * automatically.
440
497
  *
441
498
  * ```js
442
- * const http2 = require('node:http2');
443
- * const fs = require('node:fs');
499
+ * import http2 from 'node:http2';
500
+ * import fs from 'node:fs';
444
501
  *
445
502
  * const server = http2.createServer();
446
503
  * server.on('stream', (stream) => {
@@ -459,8 +516,8 @@ declare module "http2" {
459
516
  *
460
517
  * The optional `options.statCheck` function may be specified to give user code
461
518
  * an opportunity to set additional content headers based on the `fs.Stat` details
462
- * of the given fd. If the `statCheck` function is provided, the`http2stream.respondWithFD()` method will perform an `fs.fstat()` call to
463
- * collect details on the provided file descriptor.
519
+ * of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will
520
+ * perform an `fs.fstat()` call to collect details on the provided file descriptor.
464
521
  *
465
522
  * The `offset` and `length` options may be used to limit the response to a
466
523
  * specific range subset. This can be used, for instance, to support HTTP Range
@@ -478,11 +535,12 @@ declare module "http2" {
478
535
  * header fields to the peer.
479
536
  *
480
537
  * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
481
- * close when the final `DATA` frame is transmitted. User code _must_ call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
538
+ * close when the final `DATA` frame is transmitted. User code _must_ call either `http2stream.sendTrailers()`
539
+ * or `http2stream.close()` to close the `Http2Stream`.
482
540
  *
483
541
  * ```js
484
- * const http2 = require('node:http2');
485
- * const fs = require('node:fs');
542
+ * import http2 from 'node:http2';
543
+ * import fs from 'node:fs';
486
544
  *
487
545
  * const server = http2.createServer();
488
546
  * server.on('stream', (stream) => {
@@ -521,14 +579,14 @@ declare module "http2" {
521
579
  * an opportunity to set additional content headers based on the `fs.Stat` details
522
580
  * of the given file:
523
581
  *
524
- * If an error occurs while attempting to read the file data, the `Http2Stream`will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR`code. If the `onError` callback is
525
- * defined, then it will be called. Otherwise
526
- * the stream will be destroyed.
582
+ * If an error occurs while attempting to read the file data, the `Http2Stream` will be closed using an
583
+ * `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.
584
+ * If the `onError` callback is defined, then it will be called. Otherwise, the stream will be destroyed.
527
585
  *
528
586
  * Example using a file path:
529
587
  *
530
588
  * ```js
531
- * const http2 = require('node:http2');
589
+ * import http2 from 'node:http2';
532
590
  * const server = http2.createServer();
533
591
  * server.on('stream', (stream) => {
534
592
  * function statCheck(stat, headers) {
@@ -559,10 +617,10 @@ declare module "http2" {
559
617
  *
560
618
  * The `options.statCheck` function may also be used to cancel the send operation
561
619
  * by returning `false`. For instance, a conditional request may check the stat
562
- * results to determine if the file has been modified to return an appropriate`304` response:
620
+ * results to determine if the file has been modified to return an appropriate `304` response:
563
621
  *
564
622
  * ```js
565
- * const http2 = require('node:http2');
623
+ * import http2 from 'node:http2';
566
624
  * const server = http2.createServer();
567
625
  * server.on('stream', (stream) => {
568
626
  * function statCheck(stat, headers) {
@@ -595,7 +653,7 @@ declare module "http2" {
595
653
  * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
596
654
  *
597
655
  * ```js
598
- * const http2 = require('node:http2');
656
+ * import http2 from 'node:http2';
599
657
  * const server = http2.createServer();
600
658
  * server.on('stream', (stream) => {
601
659
  * stream.respondWithFile('/some/file',
@@ -623,12 +681,12 @@ declare module "http2" {
623
681
  maxConcurrentStreams?: number | undefined;
624
682
  maxHeaderListSize?: number | undefined;
625
683
  enableConnectProtocol?: boolean | undefined;
684
+ customSettings?: { [key: number]: number };
626
685
  }
627
686
  export interface ClientSessionRequestOptions {
628
687
  endStream?: boolean | undefined;
629
688
  exclusive?: boolean | undefined;
630
689
  parent?: number | undefined;
631
- weight?: number | undefined;
632
690
  waitForTrailers?: boolean | undefined;
633
691
  signal?: AbortSignal | undefined;
634
692
  }
@@ -647,18 +705,18 @@ declare module "http2" {
647
705
  /**
648
706
  * Value will be `undefined` if the `Http2Session` is not yet connected to a
649
707
  * socket, `h2c` if the `Http2Session` is not connected to a `TLSSocket`, or
650
- * will return the value of the connected `TLSSocket`'s own `alpnProtocol`property.
708
+ * will return the value of the connected `TLSSocket`'s own `alpnProtocol` property.
651
709
  * @since v9.4.0
652
710
  */
653
711
  readonly alpnProtocol?: string | undefined;
654
712
  /**
655
- * Will be `true` if this `Http2Session` instance has been closed, otherwise`false`.
713
+ * Will be `true` if this `Http2Session` instance has been closed, otherwise `false`.
656
714
  * @since v9.4.0
657
715
  */
658
716
  readonly closed: boolean;
659
717
  /**
660
718
  * Will be `true` if this `Http2Session` instance is still connecting, will be set
661
- * to `false` before emitting `connect` event and/or calling the `http2.connect`callback.
719
+ * to `false` before emitting `connect` event and/or calling the `http2.connect` callback.
662
720
  * @since v10.0.0
663
721
  */
664
722
  readonly connecting: boolean;
@@ -677,7 +735,8 @@ declare module "http2" {
677
735
  */
678
736
  readonly encrypted?: boolean | undefined;
679
737
  /**
680
- * A prototype-less object describing the current local settings of this`Http2Session`. The local settings are local to _this_`Http2Session` instance.
738
+ * A prototype-less object describing the current local settings of this `Http2Session`.
739
+ * The local settings are local to _this_`Http2Session` instance.
681
740
  * @since v8.4.0
682
741
  */
683
742
  readonly localSettings: Settings;
@@ -692,12 +751,14 @@ declare module "http2" {
692
751
  readonly originSet?: string[] | undefined;
693
752
  /**
694
753
  * Indicates whether the `Http2Session` is currently waiting for acknowledgment of
695
- * a sent `SETTINGS` frame. Will be `true` after calling the`http2session.settings()` method. Will be `false` once all sent `SETTINGS`frames have been acknowledged.
754
+ * a sent `SETTINGS` frame. Will be `true` after calling the `http2session.settings()` method.
755
+ * Will be `false` once all sent `SETTINGS` frames have been acknowledged.
696
756
  * @since v8.4.0
697
757
  */
698
758
  readonly pendingSettingsAck: boolean;
699
759
  /**
700
- * A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer.
760
+ * A prototype-less object describing the current remote settings of this`Http2Session`.
761
+ * The remote settings are set by the _connected_ HTTP/2 peer.
701
762
  * @since v8.4.0
702
763
  */
703
764
  readonly remoteSettings: Settings;
@@ -722,7 +783,7 @@ declare module "http2" {
722
783
  */
723
784
  readonly state: SessionState;
724
785
  /**
725
- * The `http2session.type` will be equal to`http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a
786
+ * The `http2session.type` will be equal to `http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a
726
787
  * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a
727
788
  * client.
728
789
  * @since v8.4.0
@@ -739,11 +800,11 @@ declare module "http2" {
739
800
  */
740
801
  close(callback?: () => void): void;
741
802
  /**
742
- * Immediately terminates the `Http2Session` and the associated `net.Socket` or`tls.TLSSocket`.
803
+ * Immediately terminates the `Http2Session` and the associated `net.Socket` or `tls.TLSSocket`.
743
804
  *
744
- * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error`is not undefined, an `'error'` event will be emitted immediately before the`'close'` event.
805
+ * Once destroyed, the `Http2Session` will emit the `'close'` event. If `error` is not undefined, an `'error'` event will be emitted immediately before the `'close'` event.
745
806
  *
746
- * If there are any remaining open `Http2Streams` associated with the`Http2Session`, those will also be destroyed.
807
+ * If there are any remaining open `Http2Streams` associated with the `Http2Session`, those will also be destroyed.
747
808
  * @since v8.4.0
748
809
  * @param error An `Error` object if the `Http2Session` is being destroyed due to an error.
749
810
  * @param code The HTTP/2 error code to send in the final `GOAWAY` frame. If unspecified, and `error` is not undefined, the default is `INTERNAL_ERROR`, otherwise defaults to `NO_ERROR`.
@@ -759,17 +820,17 @@ declare module "http2" {
759
820
  goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;
760
821
  /**
761
822
  * Sends a `PING` frame to the connected HTTP/2 peer. A `callback` function must
762
- * be provided. The method will return `true` if the `PING` was sent, `false`otherwise.
823
+ * be provided. The method will return `true` if the `PING` was sent, `false` otherwise.
763
824
  *
764
- * The maximum number of outstanding (unacknowledged) pings is determined by the`maxOutstandingPings` configuration option. The default maximum is 10.
825
+ * The maximum number of outstanding (unacknowledged) pings is determined by the `maxOutstandingPings` configuration option. The default maximum is 10.
765
826
  *
766
- * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView`containing 8 bytes of data that will be transmitted with the `PING` and
827
+ * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView` containing 8 bytes of data that will be transmitted with the `PING` and
767
828
  * returned with the ping acknowledgment.
768
829
  *
769
830
  * The callback will be invoked with three arguments: an error argument that will
770
831
  * be `null` if the `PING` was successfully acknowledged, a `duration` argument
771
832
  * that reports the number of milliseconds elapsed since the ping was sent and the
772
- * acknowledgment was received, and a `Buffer` containing the 8-byte `PING`payload.
833
+ * acknowledgment was received, and a `Buffer` containing the 8-byte `PING` payload.
773
834
  *
774
835
  * ```js
775
836
  * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
@@ -785,13 +846,13 @@ declare module "http2" {
785
846
  * @since v8.9.3
786
847
  * @param payload Optional ping payload.
787
848
  */
788
- ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
849
+ ping(callback: (err: Error | null, duration: number, payload: NonSharedBuffer) => void): boolean;
789
850
  ping(
790
851
  payload: NodeJS.ArrayBufferView,
791
- callback: (err: Error | null, duration: number, payload: Buffer) => void,
852
+ callback: (err: Error | null, duration: number, payload: NonSharedBuffer) => void,
792
853
  ): boolean;
793
854
  /**
794
- * Calls `ref()` on this `Http2Session`instance's underlying `net.Socket`.
855
+ * Calls `ref()` on this `Http2Session` instance's underlying `net.Socket`.
795
856
  * @since v9.4.0
796
857
  */
797
858
  ref(): void;
@@ -801,7 +862,7 @@ declare module "http2" {
801
862
  * the delta.
802
863
  *
803
864
  * ```js
804
- * const http2 = require('node:http2');
865
+ * import http2 from 'node:http2';
805
866
  *
806
867
  * const server = http2.createServer();
807
868
  * const expectedWindowSize = 2 ** 20;
@@ -822,9 +883,9 @@ declare module "http2" {
822
883
  */
823
884
  setTimeout(msecs: number, callback?: () => void): void;
824
885
  /**
825
- * Updates the current local settings for this `Http2Session` and sends a new`SETTINGS` frame to the connected HTTP/2 peer.
886
+ * Updates the current local settings for this `Http2Session` and sends a new `SETTINGS` frame to the connected HTTP/2 peer.
826
887
  *
827
- * Once called, the `http2session.pendingSettingsAck` property will be `true`while the session is waiting for the remote peer to acknowledge the new
888
+ * Once called, the `http2session.pendingSettingsAck` property will be `true` while the session is waiting for the remote peer to acknowledge the new
828
889
  * settings.
829
890
  *
830
891
  * The new settings will not become effective until the `SETTINGS` acknowledgment
@@ -846,11 +907,11 @@ declare module "http2" {
846
907
  addListener(event: "error", listener: (err: Error) => void): this;
847
908
  addListener(
848
909
  event: "frameError",
849
- listener: (frameType: number, errorCode: number, streamID: number) => void,
910
+ listener: (frameType: number, errorCode: number, id: number) => void,
850
911
  ): this;
851
912
  addListener(
852
913
  event: "goaway",
853
- listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
914
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer) => void,
854
915
  ): this;
855
916
  addListener(event: "localSettings", listener: (settings: Settings) => void): this;
856
917
  addListener(event: "ping", listener: () => void): this;
@@ -859,8 +920,8 @@ declare module "http2" {
859
920
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
860
921
  emit(event: "close"): boolean;
861
922
  emit(event: "error", err: Error): boolean;
862
- emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean;
863
- emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData?: Buffer): boolean;
923
+ emit(event: "frameError", frameType: number, errorCode: number, id: number): boolean;
924
+ emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer): boolean;
864
925
  emit(event: "localSettings", settings: Settings): boolean;
865
926
  emit(event: "ping"): boolean;
866
927
  emit(event: "remoteSettings", settings: Settings): boolean;
@@ -868,8 +929,11 @@ declare module "http2" {
868
929
  emit(event: string | symbol, ...args: any[]): boolean;
869
930
  on(event: "close", listener: () => void): this;
870
931
  on(event: "error", listener: (err: Error) => void): this;
871
- on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
872
- on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this;
932
+ on(event: "frameError", listener: (frameType: number, errorCode: number, id: number) => void): this;
933
+ on(
934
+ event: "goaway",
935
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer) => void,
936
+ ): this;
873
937
  on(event: "localSettings", listener: (settings: Settings) => void): this;
874
938
  on(event: "ping", listener: () => void): this;
875
939
  on(event: "remoteSettings", listener: (settings: Settings) => void): this;
@@ -877,8 +941,11 @@ declare module "http2" {
877
941
  on(event: string | symbol, listener: (...args: any[]) => void): this;
878
942
  once(event: "close", listener: () => void): this;
879
943
  once(event: "error", listener: (err: Error) => void): this;
880
- once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
881
- once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this;
944
+ once(event: "frameError", listener: (frameType: number, errorCode: number, id: number) => void): this;
945
+ once(
946
+ event: "goaway",
947
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer) => void,
948
+ ): this;
882
949
  once(event: "localSettings", listener: (settings: Settings) => void): this;
883
950
  once(event: "ping", listener: () => void): this;
884
951
  once(event: "remoteSettings", listener: (settings: Settings) => void): this;
@@ -888,11 +955,11 @@ declare module "http2" {
888
955
  prependListener(event: "error", listener: (err: Error) => void): this;
889
956
  prependListener(
890
957
  event: "frameError",
891
- listener: (frameType: number, errorCode: number, streamID: number) => void,
958
+ listener: (frameType: number, errorCode: number, id: number) => void,
892
959
  ): this;
893
960
  prependListener(
894
961
  event: "goaway",
895
- listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
962
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer) => void,
896
963
  ): this;
897
964
  prependListener(event: "localSettings", listener: (settings: Settings) => void): this;
898
965
  prependListener(event: "ping", listener: () => void): this;
@@ -903,11 +970,11 @@ declare module "http2" {
903
970
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
904
971
  prependOnceListener(
905
972
  event: "frameError",
906
- listener: (frameType: number, errorCode: number, streamID: number) => void,
973
+ listener: (frameType: number, errorCode: number, id: number) => void,
907
974
  ): this;
908
975
  prependOnceListener(
909
976
  event: "goaway",
910
- listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
977
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: NonSharedBuffer) => void,
911
978
  ): this;
912
979
  prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;
913
980
  prependOnceListener(event: "ping", listener: () => void): this;
@@ -917,18 +984,18 @@ declare module "http2" {
917
984
  }
918
985
  export interface ClientHttp2Session extends Http2Session {
919
986
  /**
920
- * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
987
+ * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()` creates and returns an `Http2Stream` instance that can be used to send an
921
988
  * HTTP/2 request to the connected server.
922
989
  *
923
990
  * When a `ClientHttp2Session` is first created, the socket may not yet be
924
991
  * connected. if `clienthttp2session.request()` is called during this time, the
925
992
  * actual request will be deferred until the socket is ready to go.
926
- * If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown.
993
+ * If the `session` is closed before the actual request be executed, an `ERR_HTTP2_GOAWAY_SESSION` is thrown.
927
994
  *
928
- * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
995
+ * This method is only available if `http2session.type` is equal to `http2.constants.NGHTTP2_SESSION_CLIENT`.
929
996
  *
930
997
  * ```js
931
- * const http2 = require('node:http2');
998
+ * import http2 from 'node:http2';
932
999
  * const clientSession = http2.connect('https://localhost:1234');
933
1000
  * const {
934
1001
  * HTTP2_HEADER_PATH,
@@ -961,7 +1028,10 @@ declare module "http2" {
961
1028
  * * `:path` \= `/`
962
1029
  * @since v8.4.0
963
1030
  */
964
- request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
1031
+ request(
1032
+ headers?: OutgoingHttpHeaders | readonly string[],
1033
+ options?: ClientSessionRequestOptions,
1034
+ ): ClientHttp2Stream;
965
1035
  addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
966
1036
  addListener(event: "origin", listener: (origins: string[]) => void): this;
967
1037
  addListener(
@@ -974,6 +1044,7 @@ declare module "http2" {
974
1044
  stream: ClientHttp2Stream,
975
1045
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
976
1046
  flags: number,
1047
+ rawHeaders: string[],
977
1048
  ) => void,
978
1049
  ): this;
979
1050
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
@@ -985,6 +1056,7 @@ declare module "http2" {
985
1056
  stream: ClientHttp2Stream,
986
1057
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
987
1058
  flags: number,
1059
+ rawHeaders: string[],
988
1060
  ): boolean;
989
1061
  emit(event: string | symbol, ...args: any[]): boolean;
990
1062
  on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
@@ -996,6 +1068,7 @@ declare module "http2" {
996
1068
  stream: ClientHttp2Stream,
997
1069
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
998
1070
  flags: number,
1071
+ rawHeaders: string[],
999
1072
  ) => void,
1000
1073
  ): this;
1001
1074
  on(event: string | symbol, listener: (...args: any[]) => void): this;
@@ -1011,6 +1084,7 @@ declare module "http2" {
1011
1084
  stream: ClientHttp2Stream,
1012
1085
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1013
1086
  flags: number,
1087
+ rawHeaders: string[],
1014
1088
  ) => void,
1015
1089
  ): this;
1016
1090
  once(event: string | symbol, listener: (...args: any[]) => void): this;
@@ -1026,6 +1100,7 @@ declare module "http2" {
1026
1100
  stream: ClientHttp2Stream,
1027
1101
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1028
1102
  flags: number,
1103
+ rawHeaders: string[],
1029
1104
  ) => void,
1030
1105
  ): this;
1031
1106
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
@@ -1041,6 +1116,7 @@ declare module "http2" {
1041
1116
  stream: ClientHttp2Stream,
1042
1117
  headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1043
1118
  flags: number,
1119
+ rawHeaders: string[],
1044
1120
  ) => void,
1045
1121
  ): this;
1046
1122
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
@@ -1048,13 +1124,20 @@ declare module "http2" {
1048
1124
  export interface AlternativeServiceOptions {
1049
1125
  origin: number | string | url.URL;
1050
1126
  }
1051
- export interface ServerHttp2Session extends Http2Session {
1052
- readonly server: Http2Server | Http2SecureServer;
1127
+ export interface ServerHttp2Session<
1128
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1129
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1130
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1131
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1132
+ > extends Http2Session {
1133
+ readonly server:
1134
+ | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
1135
+ | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
1053
1136
  /**
1054
1137
  * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1055
1138
  *
1056
1139
  * ```js
1057
- * const http2 = require('node:http2');
1140
+ * import http2 from 'node:http2';
1058
1141
  *
1059
1142
  * const server = http2.createServer();
1060
1143
  * server.on('session', (session) => {
@@ -1095,7 +1178,7 @@ declare module "http2" {
1095
1178
  * authoritative responses.
1096
1179
  *
1097
1180
  * ```js
1098
- * const http2 = require('node:http2');
1181
+ * import http2 from 'node:http2';
1099
1182
  * const options = getSecureOptionsSomehow();
1100
1183
  * const server = http2.createSecureServer(options);
1101
1184
  * server.on('stream', (stream) => {
@@ -1108,7 +1191,7 @@ declare module "http2" {
1108
1191
  * ```
1109
1192
  *
1110
1193
  * When a string is passed as an `origin`, it will be parsed as a URL and the
1111
- * origin will be derived. For instance, the origin for the HTTP URL`'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given
1194
+ * origin will be derived. For instance, the origin for the HTTP URL `'https://example.org/foo/bar'` is the ASCII string` 'https://example.org'`. An error will be thrown if either the given
1112
1195
  * string
1113
1196
  * cannot be parsed as a URL or if a valid origin cannot be derived.
1114
1197
  *
@@ -1121,7 +1204,7 @@ declare module "http2" {
1121
1204
  * server using the `http2.createSecureServer()` method:
1122
1205
  *
1123
1206
  * ```js
1124
- * const http2 = require('node:http2');
1207
+ * import http2 from 'node:http2';
1125
1208
  * const options = getSecureOptionsSomehow();
1126
1209
  * options.origins = ['https://example.com', 'https://example.org'];
1127
1210
  * const server = http2.createSecureServer(options);
@@ -1144,60 +1227,166 @@ declare module "http2" {
1144
1227
  ): void;
1145
1228
  addListener(
1146
1229
  event: "connect",
1147
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1230
+ listener: (
1231
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1232
+ socket: net.Socket | tls.TLSSocket,
1233
+ ) => void,
1148
1234
  ): this;
1149
1235
  addListener(
1150
1236
  event: "stream",
1151
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1237
+ listener: (
1238
+ stream: ServerHttp2Stream,
1239
+ headers: IncomingHttpHeaders,
1240
+ flags: number,
1241
+ rawHeaders: string[],
1242
+ ) => void,
1152
1243
  ): this;
1153
1244
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1154
- emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
1155
- emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1245
+ emit(
1246
+ event: "connect",
1247
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1248
+ socket: net.Socket | tls.TLSSocket,
1249
+ ): boolean;
1250
+ emit(
1251
+ event: "stream",
1252
+ stream: ServerHttp2Stream,
1253
+ headers: IncomingHttpHeaders,
1254
+ flags: number,
1255
+ rawHeaders: string[],
1256
+ ): boolean;
1156
1257
  emit(event: string | symbol, ...args: any[]): boolean;
1157
- on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1258
+ on(
1259
+ event: "connect",
1260
+ listener: (
1261
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1262
+ socket: net.Socket | tls.TLSSocket,
1263
+ ) => void,
1264
+ ): this;
1158
1265
  on(
1159
1266
  event: "stream",
1160
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1267
+ listener: (
1268
+ stream: ServerHttp2Stream,
1269
+ headers: IncomingHttpHeaders,
1270
+ flags: number,
1271
+ rawHeaders: string[],
1272
+ ) => void,
1161
1273
  ): this;
1162
1274
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1163
1275
  once(
1164
1276
  event: "connect",
1165
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1277
+ listener: (
1278
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1279
+ socket: net.Socket | tls.TLSSocket,
1280
+ ) => void,
1166
1281
  ): this;
1167
1282
  once(
1168
1283
  event: "stream",
1169
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1284
+ listener: (
1285
+ stream: ServerHttp2Stream,
1286
+ headers: IncomingHttpHeaders,
1287
+ flags: number,
1288
+ rawHeaders: string[],
1289
+ ) => void,
1170
1290
  ): this;
1171
1291
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1172
1292
  prependListener(
1173
1293
  event: "connect",
1174
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1294
+ listener: (
1295
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1296
+ socket: net.Socket | tls.TLSSocket,
1297
+ ) => void,
1175
1298
  ): this;
1176
1299
  prependListener(
1177
1300
  event: "stream",
1178
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1301
+ listener: (
1302
+ stream: ServerHttp2Stream,
1303
+ headers: IncomingHttpHeaders,
1304
+ flags: number,
1305
+ rawHeaders: string[],
1306
+ ) => void,
1179
1307
  ): this;
1180
1308
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1181
1309
  prependOnceListener(
1182
1310
  event: "connect",
1183
- listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1311
+ listener: (
1312
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1313
+ socket: net.Socket | tls.TLSSocket,
1314
+ ) => void,
1184
1315
  ): this;
1185
1316
  prependOnceListener(
1186
1317
  event: "stream",
1187
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1318
+ listener: (
1319
+ stream: ServerHttp2Stream,
1320
+ headers: IncomingHttpHeaders,
1321
+ flags: number,
1322
+ rawHeaders: string[],
1323
+ ) => void,
1188
1324
  ): this;
1189
1325
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1190
1326
  }
1191
1327
  // Http2Server
1192
1328
  export interface SessionOptions {
1329
+ /**
1330
+ * Sets the maximum dynamic table size for deflating header fields.
1331
+ * @default 4Kib
1332
+ */
1193
1333
  maxDeflateDynamicTableSize?: number | undefined;
1334
+ /**
1335
+ * Sets the maximum number of settings entries per `SETTINGS` frame.
1336
+ * The minimum value allowed is `1`.
1337
+ * @default 32
1338
+ */
1339
+ maxSettings?: number | undefined;
1340
+ /**
1341
+ * Sets the maximum memory that the `Http2Session` is permitted to use.
1342
+ * The value is expressed in terms of number of megabytes, e.g. `1` equal 1 megabyte.
1343
+ * The minimum value allowed is `1`.
1344
+ * This is a credit based limit, existing `Http2Stream`s may cause this limit to be exceeded,
1345
+ * but new `Http2Stream` instances will be rejected while this limit is exceeded.
1346
+ * The current number of `Http2Stream` sessions, the current memory use of the header compression tables,
1347
+ * current data queued to be sent, and unacknowledged `PING` and `SETTINGS` frames are all counted towards the current limit.
1348
+ * @default 10
1349
+ */
1194
1350
  maxSessionMemory?: number | undefined;
1351
+ /**
1352
+ * Sets the maximum number of header entries.
1353
+ * This is similar to `server.maxHeadersCount` or `request.maxHeadersCount` in the `node:http` module.
1354
+ * The minimum value is `1`.
1355
+ * @default 128
1356
+ */
1195
1357
  maxHeaderListPairs?: number | undefined;
1358
+ /**
1359
+ * Sets the maximum number of outstanding, unacknowledged pings.
1360
+ * @default 10
1361
+ */
1196
1362
  maxOutstandingPings?: number | undefined;
1363
+ /**
1364
+ * Sets the maximum allowed size for a serialized, compressed block of headers.
1365
+ * Attempts to send headers that exceed this limit will result in
1366
+ * a `'frameError'` event being emitted and the stream being closed and destroyed.
1367
+ */
1197
1368
  maxSendHeaderBlockLength?: number | undefined;
1369
+ /**
1370
+ * Strategy used for determining the amount of padding to use for `HEADERS` and `DATA` frames.
1371
+ * @default http2.constants.PADDING_STRATEGY_NONE
1372
+ */
1198
1373
  paddingStrategy?: number | undefined;
1374
+ /**
1375
+ * Sets the maximum number of concurrent streams for the remote peer as if a `SETTINGS` frame had been received.
1376
+ * Will be overridden if the remote peer sets its own value for `maxConcurrentStreams`.
1377
+ * @default 100
1378
+ */
1199
1379
  peerMaxConcurrentStreams?: number | undefined;
1380
+ /**
1381
+ * The initial settings to send to the remote peer upon connection.
1382
+ */
1200
1383
  settings?: Settings | undefined;
1384
+ /**
1385
+ * The array of integer values determines the settings types,
1386
+ * which are included in the `CustomSettings`-property of the received remoteSettings.
1387
+ * Please see the `CustomSettings`-property of the `Http2Settings` object for more information, on the allowed setting types.
1388
+ */
1389
+ remoteCustomSettings?: number[] | undefined;
1201
1390
  /**
1202
1391
  * Specifies a timeout in milliseconds that
1203
1392
  * a server should wait when an [`'unknownProtocol'`][] is emitted. If the
@@ -1205,23 +1394,71 @@ declare module "http2" {
1205
1394
  * @default 100000
1206
1395
  */
1207
1396
  unknownProtocolTimeout?: number | undefined;
1208
- selectPadding?(frameLen: number, maxFrameLen: number): number;
1397
+ /**
1398
+ * If `true`, it turns on strict leading
1399
+ * and trailing whitespace validation for HTTP/2 header field names and values
1400
+ * as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1).
1401
+ * @since v24.2.0
1402
+ * @default true
1403
+ */
1404
+ strictFieldWhitespaceValidation?: boolean | undefined;
1209
1405
  }
1210
1406
  export interface ClientSessionOptions extends SessionOptions {
1407
+ /**
1408
+ * Sets the maximum number of reserved push streams the client will accept at any given time.
1409
+ * Once the current number of currently reserved push streams exceeds reaches this limit,
1410
+ * new push streams sent by the server will be automatically rejected.
1411
+ * The minimum allowed value is 0. The maximum allowed value is 2<sup>32</sup>-1.
1412
+ * A negative value sets this option to the maximum allowed value.
1413
+ * @default 200
1414
+ */
1211
1415
  maxReservedRemoteStreams?: number | undefined;
1416
+ /**
1417
+ * An optional callback that receives the `URL` instance passed to `connect` and the `options` object,
1418
+ * and returns any `Duplex` stream that is to be used as the connection for this session.
1419
+ */
1212
1420
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1421
+ /**
1422
+ * The protocol to connect with, if not set in the `authority`.
1423
+ * Value may be either `'http:'` or `'https:'`.
1424
+ * @default 'https:'
1425
+ */
1213
1426
  protocol?: "http:" | "https:" | undefined;
1214
1427
  }
1215
- export interface ServerSessionOptions extends SessionOptions {
1216
- Http1IncomingMessage?: typeof IncomingMessage | undefined;
1217
- Http1ServerResponse?: typeof ServerResponse | undefined;
1218
- Http2ServerRequest?: typeof Http2ServerRequest | undefined;
1219
- Http2ServerResponse?: typeof Http2ServerResponse | undefined;
1428
+ export interface ServerSessionOptions<
1429
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1430
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1431
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1432
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1433
+ > extends SessionOptions {
1434
+ maxSessionRejectedStreams?: number | undefined;
1435
+ maxSessionInvalidFrames?: number | undefined;
1436
+ streamResetBurst?: number | undefined;
1437
+ streamResetRate?: number | undefined;
1438
+ Http1IncomingMessage?: Http1Request | undefined;
1439
+ Http1ServerResponse?: Http1Response | undefined;
1440
+ Http2ServerRequest?: Http2Request | undefined;
1441
+ Http2ServerResponse?: Http2Response | undefined;
1220
1442
  }
1221
1443
  export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {}
1222
- export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions {}
1223
- export interface ServerOptions extends ServerSessionOptions {}
1224
- export interface SecureServerOptions extends SecureServerSessionOptions {
1444
+ export interface SecureServerSessionOptions<
1445
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1446
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1447
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1448
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1449
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response>, tls.TlsOptions {}
1450
+ export interface ServerOptions<
1451
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1452
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1453
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1454
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1455
+ > extends ServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {}
1456
+ export interface SecureServerOptions<
1457
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1458
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1459
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1460
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1461
+ > extends SecureServerSessionOptions<Http1Request, Http1Response, Http2Request, Http2Response> {
1225
1462
  allowHTTP1?: boolean | undefined;
1226
1463
  origins?: string[] | undefined;
1227
1464
  }
@@ -1233,100 +1470,210 @@ declare module "http2" {
1233
1470
  */
1234
1471
  updateSettings(settings: Settings): void;
1235
1472
  }
1236
- export interface Http2Server extends net.Server, HTTP2ServerCommon {
1473
+ export interface Http2Server<
1474
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1475
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1476
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1477
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1478
+ > extends net.Server, HTTP2ServerCommon {
1237
1479
  addListener(
1238
1480
  event: "checkContinue",
1239
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1481
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1240
1482
  ): this;
1241
1483
  addListener(
1242
1484
  event: "request",
1243
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1485
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1486
+ ): this;
1487
+ addListener(
1488
+ event: "session",
1489
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1490
+ ): this;
1491
+ addListener(
1492
+ event: "sessionError",
1493
+ listener: (
1494
+ err: Error,
1495
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1496
+ ) => void,
1244
1497
  ): this;
1245
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1246
- addListener(event: "sessionError", listener: (err: Error) => void): this;
1247
1498
  addListener(
1248
1499
  event: "stream",
1249
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1500
+ listener: (
1501
+ stream: ServerHttp2Stream,
1502
+ headers: IncomingHttpHeaders,
1503
+ flags: number,
1504
+ rawHeaders: string[],
1505
+ ) => void,
1250
1506
  ): this;
1251
1507
  addListener(event: "timeout", listener: () => void): this;
1252
1508
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1253
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1254
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1255
- emit(event: "session", session: ServerHttp2Session): boolean;
1256
- emit(event: "sessionError", err: Error): boolean;
1257
- emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1509
+ emit(
1510
+ event: "checkContinue",
1511
+ request: InstanceType<Http2Request>,
1512
+ response: InstanceType<Http2Response>,
1513
+ ): boolean;
1514
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1515
+ emit(
1516
+ event: "session",
1517
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1518
+ ): boolean;
1519
+ emit(
1520
+ event: "sessionError",
1521
+ err: Error,
1522
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1523
+ ): boolean;
1524
+ emit(
1525
+ event: "stream",
1526
+ stream: ServerHttp2Stream,
1527
+ headers: IncomingHttpHeaders,
1528
+ flags: number,
1529
+ rawHeaders: string[],
1530
+ ): boolean;
1258
1531
  emit(event: "timeout"): boolean;
1259
1532
  emit(event: string | symbol, ...args: any[]): boolean;
1260
1533
  on(
1261
1534
  event: "checkContinue",
1262
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1535
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1536
+ ): this;
1537
+ on(
1538
+ event: "request",
1539
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1540
+ ): this;
1541
+ on(
1542
+ event: "session",
1543
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1544
+ ): this;
1545
+ on(
1546
+ event: "sessionError",
1547
+ listener: (
1548
+ err: Error,
1549
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1550
+ ) => void,
1263
1551
  ): this;
1264
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1265
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1266
- on(event: "sessionError", listener: (err: Error) => void): this;
1267
1552
  on(
1268
1553
  event: "stream",
1269
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1554
+ listener: (
1555
+ stream: ServerHttp2Stream,
1556
+ headers: IncomingHttpHeaders,
1557
+ flags: number,
1558
+ rawHeaders: string[],
1559
+ ) => void,
1270
1560
  ): this;
1271
1561
  on(event: "timeout", listener: () => void): this;
1272
1562
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1273
1563
  once(
1274
1564
  event: "checkContinue",
1275
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1565
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1566
+ ): this;
1567
+ once(
1568
+ event: "request",
1569
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1570
+ ): this;
1571
+ once(
1572
+ event: "session",
1573
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1574
+ ): this;
1575
+ once(
1576
+ event: "sessionError",
1577
+ listener: (
1578
+ err: Error,
1579
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1580
+ ) => void,
1276
1581
  ): this;
1277
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1278
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1279
- once(event: "sessionError", listener: (err: Error) => void): this;
1280
1582
  once(
1281
1583
  event: "stream",
1282
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1584
+ listener: (
1585
+ stream: ServerHttp2Stream,
1586
+ headers: IncomingHttpHeaders,
1587
+ flags: number,
1588
+ rawHeaders: string[],
1589
+ ) => void,
1283
1590
  ): this;
1284
1591
  once(event: "timeout", listener: () => void): this;
1285
1592
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1286
1593
  prependListener(
1287
1594
  event: "checkContinue",
1288
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1595
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1289
1596
  ): this;
1290
1597
  prependListener(
1291
1598
  event: "request",
1292
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1599
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1600
+ ): this;
1601
+ prependListener(
1602
+ event: "session",
1603
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1604
+ ): this;
1605
+ prependListener(
1606
+ event: "sessionError",
1607
+ listener: (
1608
+ err: Error,
1609
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1610
+ ) => void,
1293
1611
  ): this;
1294
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1295
- prependListener(event: "sessionError", listener: (err: Error) => void): this;
1296
1612
  prependListener(
1297
1613
  event: "stream",
1298
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1614
+ listener: (
1615
+ stream: ServerHttp2Stream,
1616
+ headers: IncomingHttpHeaders,
1617
+ flags: number,
1618
+ rawHeaders: string[],
1619
+ ) => void,
1299
1620
  ): this;
1300
1621
  prependListener(event: "timeout", listener: () => void): this;
1301
1622
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1302
1623
  prependOnceListener(
1303
1624
  event: "checkContinue",
1304
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1625
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1305
1626
  ): this;
1306
1627
  prependOnceListener(
1307
1628
  event: "request",
1308
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1629
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1630
+ ): this;
1631
+ prependOnceListener(
1632
+ event: "session",
1633
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1634
+ ): this;
1635
+ prependOnceListener(
1636
+ event: "sessionError",
1637
+ listener: (
1638
+ err: Error,
1639
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1640
+ ) => void,
1309
1641
  ): this;
1310
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1311
- prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1312
1642
  prependOnceListener(
1313
1643
  event: "stream",
1314
- listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1644
+ listener: (
1645
+ stream: ServerHttp2Stream,
1646
+ headers: IncomingHttpHeaders,
1647
+ flags: number,
1648
+ rawHeaders: string[],
1649
+ ) => void,
1315
1650
  ): this;
1316
1651
  prependOnceListener(event: "timeout", listener: () => void): this;
1317
1652
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1318
1653
  }
1319
- export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1654
+ export interface Http2SecureServer<
1655
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
1656
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
1657
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
1658
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
1659
+ > extends tls.Server, HTTP2ServerCommon {
1320
1660
  addListener(
1321
1661
  event: "checkContinue",
1322
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1662
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1323
1663
  ): this;
1324
1664
  addListener(
1325
1665
  event: "request",
1326
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1666
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1667
+ ): this;
1668
+ addListener(
1669
+ event: "session",
1670
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1671
+ ): this;
1672
+ addListener(
1673
+ event: "sessionError",
1674
+ listener: (err: Error) => void,
1675
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1327
1676
  ): this;
1328
- addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1329
- addListener(event: "sessionError", listener: (err: Error) => void): this;
1330
1677
  addListener(
1331
1678
  event: "stream",
1332
1679
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1334,21 +1681,44 @@ declare module "http2" {
1334
1681
  addListener(event: "timeout", listener: () => void): this;
1335
1682
  addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1336
1683
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1337
- emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1338
- emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
1339
- emit(event: "session", session: ServerHttp2Session): boolean;
1340
- emit(event: "sessionError", err: Error): boolean;
1684
+ emit(
1685
+ event: "checkContinue",
1686
+ request: InstanceType<Http2Request>,
1687
+ response: InstanceType<Http2Response>,
1688
+ ): boolean;
1689
+ emit(event: "request", request: InstanceType<Http2Request>, response: InstanceType<Http2Response>): boolean;
1690
+ emit(
1691
+ event: "session",
1692
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1693
+ ): boolean;
1694
+ emit(
1695
+ event: "sessionError",
1696
+ err: Error,
1697
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1698
+ ): boolean;
1341
1699
  emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1342
1700
  emit(event: "timeout"): boolean;
1343
1701
  emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean;
1344
1702
  emit(event: string | symbol, ...args: any[]): boolean;
1345
1703
  on(
1346
1704
  event: "checkContinue",
1347
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1705
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1706
+ ): this;
1707
+ on(
1708
+ event: "request",
1709
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1710
+ ): this;
1711
+ on(
1712
+ event: "session",
1713
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1714
+ ): this;
1715
+ on(
1716
+ event: "sessionError",
1717
+ listener: (
1718
+ err: Error,
1719
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1720
+ ) => void,
1348
1721
  ): this;
1349
- on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1350
- on(event: "session", listener: (session: ServerHttp2Session) => void): this;
1351
- on(event: "sessionError", listener: (err: Error) => void): this;
1352
1722
  on(
1353
1723
  event: "stream",
1354
1724
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1358,11 +1728,23 @@ declare module "http2" {
1358
1728
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1359
1729
  once(
1360
1730
  event: "checkContinue",
1361
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1731
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1732
+ ): this;
1733
+ once(
1734
+ event: "request",
1735
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1736
+ ): this;
1737
+ once(
1738
+ event: "session",
1739
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1740
+ ): this;
1741
+ once(
1742
+ event: "sessionError",
1743
+ listener: (
1744
+ err: Error,
1745
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1746
+ ) => void,
1362
1747
  ): this;
1363
- once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
1364
- once(event: "session", listener: (session: ServerHttp2Session) => void): this;
1365
- once(event: "sessionError", listener: (err: Error) => void): this;
1366
1748
  once(
1367
1749
  event: "stream",
1368
1750
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1372,14 +1754,23 @@ declare module "http2" {
1372
1754
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1373
1755
  prependListener(
1374
1756
  event: "checkContinue",
1375
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1757
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1376
1758
  ): this;
1377
1759
  prependListener(
1378
1760
  event: "request",
1379
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1761
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1762
+ ): this;
1763
+ prependListener(
1764
+ event: "session",
1765
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1766
+ ): this;
1767
+ prependListener(
1768
+ event: "sessionError",
1769
+ listener: (
1770
+ err: Error,
1771
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1772
+ ) => void,
1380
1773
  ): this;
1381
- prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1382
- prependListener(event: "sessionError", listener: (err: Error) => void): this;
1383
1774
  prependListener(
1384
1775
  event: "stream",
1385
1776
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1389,14 +1780,23 @@ declare module "http2" {
1389
1780
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1390
1781
  prependOnceListener(
1391
1782
  event: "checkContinue",
1392
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1783
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1393
1784
  ): this;
1394
1785
  prependOnceListener(
1395
1786
  event: "request",
1396
- listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1787
+ listener: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
1788
+ ): this;
1789
+ prependOnceListener(
1790
+ event: "session",
1791
+ listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,
1792
+ ): this;
1793
+ prependOnceListener(
1794
+ event: "sessionError",
1795
+ listener: (
1796
+ err: Error,
1797
+ session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,
1798
+ ) => void,
1397
1799
  ): this;
1398
- prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1399
- prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1400
1800
  prependOnceListener(
1401
1801
  event: "stream",
1402
1802
  listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
@@ -1426,7 +1826,7 @@ declare module "http2" {
1426
1826
  readonly aborted: boolean;
1427
1827
  /**
1428
1828
  * The request authority pseudo header field. Because HTTP/2 allows requests
1429
- * to set either `:authority` or `host`, this value is derived from`req.headers[':authority']` if present. Otherwise, it is derived from`req.headers['host']`.
1829
+ * to set either `:authority` or `host`, this value is derived from `req.headers[':authority']` if present. Otherwise, it is derived from `req.headers['host']`.
1430
1830
  * @since v8.4.0
1431
1831
  */
1432
1832
  readonly authority: string;
@@ -1473,9 +1873,9 @@ declare module "http2" {
1473
1873
  readonly headers: IncomingHttpHeaders;
1474
1874
  /**
1475
1875
  * In case of server request, the HTTP version sent by the client. In the case of
1476
- * client response, the HTTP version of the connected-to server. Returns`'2.0'`.
1876
+ * client response, the HTTP version of the connected-to server. Returns `'2.0'`.
1477
1877
  *
1478
- * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1878
+ * Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second.
1479
1879
  * @since v8.4.0
1480
1880
  */
1481
1881
  readonly httpVersion: string;
@@ -1530,11 +1930,11 @@ declare module "http2" {
1530
1930
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1531
1931
  * set on `request.stream`.
1532
1932
  *
1533
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`.
1933
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `request.stream`.
1534
1934
  *
1535
1935
  * `setTimeout` method will be called on `request.stream.session`.
1536
1936
  *
1537
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1937
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1538
1938
  * more information.
1539
1939
  *
1540
1940
  * All other interactions will be routed directly to the socket. With TLS support,
@@ -1597,50 +1997,50 @@ declare module "http2" {
1597
1997
  * the response object.
1598
1998
  *
1599
1999
  * If no `'timeout'` listener is added to the request, the response, or
1600
- * the server, then `Http2Stream` s are destroyed when they time out. If a
2000
+ * the server, then `Http2Stream`s are destroyed when they time out. If a
1601
2001
  * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1602
2002
  * @since v8.4.0
1603
2003
  */
1604
2004
  setTimeout(msecs: number, callback?: () => void): void;
1605
- read(size?: number): Buffer | string | null;
2005
+ read(size?: number): NonSharedBuffer | string | null;
1606
2006
  addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1607
2007
  addListener(event: "close", listener: () => void): this;
1608
- addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
2008
+ addListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
1609
2009
  addListener(event: "end", listener: () => void): this;
1610
2010
  addListener(event: "readable", listener: () => void): this;
1611
2011
  addListener(event: "error", listener: (err: Error) => void): this;
1612
2012
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1613
2013
  emit(event: "aborted", hadError: boolean, code: number): boolean;
1614
2014
  emit(event: "close"): boolean;
1615
- emit(event: "data", chunk: Buffer | string): boolean;
2015
+ emit(event: "data", chunk: NonSharedBuffer | string): boolean;
1616
2016
  emit(event: "end"): boolean;
1617
2017
  emit(event: "readable"): boolean;
1618
2018
  emit(event: "error", err: Error): boolean;
1619
2019
  emit(event: string | symbol, ...args: any[]): boolean;
1620
2020
  on(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1621
2021
  on(event: "close", listener: () => void): this;
1622
- on(event: "data", listener: (chunk: Buffer | string) => void): this;
2022
+ on(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
1623
2023
  on(event: "end", listener: () => void): this;
1624
2024
  on(event: "readable", listener: () => void): this;
1625
2025
  on(event: "error", listener: (err: Error) => void): this;
1626
2026
  on(event: string | symbol, listener: (...args: any[]) => void): this;
1627
2027
  once(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1628
2028
  once(event: "close", listener: () => void): this;
1629
- once(event: "data", listener: (chunk: Buffer | string) => void): this;
2029
+ once(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
1630
2030
  once(event: "end", listener: () => void): this;
1631
2031
  once(event: "readable", listener: () => void): this;
1632
2032
  once(event: "error", listener: (err: Error) => void): this;
1633
2033
  once(event: string | symbol, listener: (...args: any[]) => void): this;
1634
2034
  prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1635
2035
  prependListener(event: "close", listener: () => void): this;
1636
- prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
2036
+ prependListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
1637
2037
  prependListener(event: "end", listener: () => void): this;
1638
2038
  prependListener(event: "readable", listener: () => void): this;
1639
2039
  prependListener(event: "error", listener: (err: Error) => void): this;
1640
2040
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1641
2041
  prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1642
2042
  prependOnceListener(event: "close", listener: () => void): this;
1643
- prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
2043
+ prependOnceListener(event: "data", listener: (chunk: NonSharedBuffer | string) => void): this;
1644
2044
  prependOnceListener(event: "end", listener: () => void): this;
1645
2045
  prependOnceListener(event: "readable", listener: () => void): this;
1646
2046
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
@@ -1651,7 +2051,7 @@ declare module "http2" {
1651
2051
  * passed as the second parameter to the `'request'` event.
1652
2052
  * @since v8.4.0
1653
2053
  */
1654
- export class Http2ServerResponse extends stream.Writable {
2054
+ export class Http2ServerResponse<Request extends Http2ServerRequest = Http2ServerRequest> extends stream.Writable {
1655
2055
  constructor(stream: ServerHttp2Stream);
1656
2056
  /**
1657
2057
  * See `response.socket`.
@@ -1659,6 +2059,28 @@ declare module "http2" {
1659
2059
  * @deprecated Since v13.0.0 - Use `socket`.
1660
2060
  */
1661
2061
  readonly connection: net.Socket | tls.TLSSocket;
2062
+ /**
2063
+ * Append a single header value to the header object.
2064
+ *
2065
+ * If the value is an array, this is equivalent to calling this method multiple times.
2066
+ *
2067
+ * If there were no previous values for the header, this is equivalent to calling {@link setHeader}.
2068
+ *
2069
+ * Attempting to set a header field name or value that contains invalid characters will result in a
2070
+ * [TypeError](https://nodejs.org/docs/latest-v24.x/api/errors.html#class-typeerror) being thrown.
2071
+ *
2072
+ * ```js
2073
+ * // Returns headers including "set-cookie: a" and "set-cookie: b"
2074
+ * const server = http2.createServer((req, res) => {
2075
+ * res.setHeader('set-cookie', 'a');
2076
+ * res.appendHeader('set-cookie', 'b');
2077
+ * res.writeHead(200);
2078
+ * res.end('ok');
2079
+ * });
2080
+ * ```
2081
+ * @since v20.12.0
2082
+ */
2083
+ appendHeader(name: string, value: string | string[]): void;
1662
2084
  /**
1663
2085
  * Boolean value that indicates whether the response has completed. Starts
1664
2086
  * as `false`. After `response.end()` executes, the value will be `true`.
@@ -1675,7 +2097,7 @@ declare module "http2" {
1675
2097
  * A reference to the original HTTP2 `request` object.
1676
2098
  * @since v15.7.0
1677
2099
  */
1678
- readonly req: Http2ServerRequest;
2100
+ readonly req: Request;
1679
2101
  /**
1680
2102
  * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1681
2103
  * applies getters, setters, and methods based on HTTP/2 logic.
@@ -1683,17 +2105,17 @@ declare module "http2" {
1683
2105
  * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1684
2106
  * set on `response.stream`.
1685
2107
  *
1686
- * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`.
2108
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on `response.stream`.
1687
2109
  *
1688
2110
  * `setTimeout` method will be called on `response.stream.session`.
1689
2111
  *
1690
- * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
2112
+ * `pause`, `read`, `resume`, and `write` will throw an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1691
2113
  * more information.
1692
2114
  *
1693
2115
  * All other interactions will be routed directly to the socket.
1694
2116
  *
1695
2117
  * ```js
1696
- * const http2 = require('node:http2');
2118
+ * import http2 from 'node:http2';
1697
2119
  * const server = http2.createServer((req, res) => {
1698
2120
  * const ip = req.socket.remoteAddress;
1699
2121
  * const port = req.socket.remotePort;
@@ -1791,7 +2213,7 @@ declare module "http2" {
1791
2213
  * header names and the values are the respective header values. All header names
1792
2214
  * are lowercase.
1793
2215
  *
1794
- * The object returned by the `response.getHeaders()` method _does not_prototypically inherit from the JavaScript `Object`. This means that typical`Object` methods such as `obj.toString()`,
2216
+ * The object returned by the `response.getHeaders()` method _does not_ prototypically inherit from the JavaScript `Object`. This means that typical `Object` methods such as `obj.toString()`,
1795
2217
  * `obj.hasOwnProperty()`, and others
1796
2218
  * are not defined and _will not work_.
1797
2219
  *
@@ -1865,7 +2287,7 @@ declare module "http2" {
1865
2287
  *
1866
2288
  * If no `'timeout'` listener is added to the request, the response, or
1867
2289
  * the server, then `Http2Stream` s are destroyed when they time out. If a
1868
- * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
2290
+ * handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly.
1869
2291
  * @since v8.4.0
1870
2292
  */
1871
2293
  setTimeout(msecs: number, callback?: () => void): void;
@@ -1901,7 +2323,7 @@ declare module "http2" {
1901
2323
  write(chunk: string | Uint8Array, encoding: BufferEncoding, callback?: (err: Error) => void): boolean;
1902
2324
  /**
1903
2325
  * Sends a status `100 Continue` to the client, indicating that the request body
1904
- * should be sent. See the `'checkContinue'` event on `Http2Server` and`Http2SecureServer`.
2326
+ * should be sent. See the `'checkContinue'` event on `Http2Server` and `Http2SecureServer`.
1905
2327
  * @since v8.4.0
1906
2328
  */
1907
2329
  writeContinue(): void;
@@ -1952,7 +2374,7 @@ declare module "http2" {
1952
2374
  * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a
1953
2375
  * given encoding. On outbound messages, Node.js does not check if Content-Length
1954
2376
  * and the length of the body being transmitted are equal or not. However, when
1955
- * receiving messages, Node.js will automatically reject messages when the`Content-Length` does not match the actual payload size.
2377
+ * receiving messages, Node.js will automatically reject messages when the `Content-Length` does not match the actual payload size.
1956
2378
  *
1957
2379
  * This method may be called at most one time on a message before `response.end()` is called.
1958
2380
  *
@@ -1977,8 +2399,8 @@ declare module "http2" {
1977
2399
  * will result in a `TypeError` being thrown.
1978
2400
  * @since v8.4.0
1979
2401
  */
1980
- writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this;
1981
- writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this;
2402
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders | readonly string[]): this;
2403
+ writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders | readonly string[]): this;
1982
2404
  /**
1983
2405
  * Call `http2stream.pushStream()` with the given headers, and wrap the
1984
2406
  * given `Http2Stream` on a newly created `Http2ServerResponse` as the callback
@@ -2094,7 +2516,13 @@ declare module "http2" {
2094
2516
  const HTTP2_HEADER_ACCEPT_LANGUAGE: string;
2095
2517
  const HTTP2_HEADER_ACCEPT_RANGES: string;
2096
2518
  const HTTP2_HEADER_ACCEPT: string;
2519
+ const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS: string;
2520
+ const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS: string;
2521
+ const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS: string;
2097
2522
  const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string;
2523
+ const HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS: string;
2524
+ const HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS: string;
2525
+ const HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD: string;
2098
2526
  const HTTP2_HEADER_AGE: string;
2099
2527
  const HTTP2_HEADER_ALLOW: string;
2100
2528
  const HTTP2_HEADER_AUTHORIZATION: string;
@@ -2252,7 +2680,7 @@ declare module "http2" {
2252
2680
  */
2253
2681
  export const sensitiveHeaders: symbol;
2254
2682
  /**
2255
- * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called
2683
+ * Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called
2256
2684
  * so instances returned may be safely modified for use.
2257
2685
  * @since v8.4.0
2258
2686
  */
@@ -2263,7 +2691,7 @@ declare module "http2" {
2263
2691
  * for use with the `HTTP2-Settings` header field.
2264
2692
  *
2265
2693
  * ```js
2266
- * const http2 = require('node:http2');
2694
+ * import http2 from 'node:http2';
2267
2695
  *
2268
2696
  * const packed = http2.getPackedSettings({ enablePush: false });
2269
2697
  *
@@ -2272,7 +2700,7 @@ declare module "http2" {
2272
2700
  * ```
2273
2701
  * @since v8.4.0
2274
2702
  */
2275
- export function getPackedSettings(settings: Settings): Buffer;
2703
+ export function getPackedSettings(settings: Settings): NonSharedBuffer;
2276
2704
  /**
2277
2705
  * Returns a `HTTP/2 Settings Object` containing the deserialized settings from
2278
2706
  * the given `Buffer` as generated by `http2.getPackedSettings()`.
@@ -2281,14 +2709,14 @@ declare module "http2" {
2281
2709
  */
2282
2710
  export function getUnpackedSettings(buf: Uint8Array): Settings;
2283
2711
  /**
2284
- * Returns a `net.Server` instance that creates and manages `Http2Session`instances.
2712
+ * Returns a `net.Server` instance that creates and manages `Http2Session` instances.
2285
2713
  *
2286
2714
  * Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of {@link createSecureServer} is necessary when
2287
2715
  * communicating
2288
2716
  * with browser clients.
2289
2717
  *
2290
2718
  * ```js
2291
- * const http2 = require('node:http2');
2719
+ * import http2 from 'node:http2';
2292
2720
  *
2293
2721
  * // Create an unencrypted HTTP/2 server.
2294
2722
  * // Since there are no browsers known that support
@@ -2312,16 +2740,21 @@ declare module "http2" {
2312
2740
  export function createServer(
2313
2741
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2314
2742
  ): Http2Server;
2315
- export function createServer(
2316
- options: ServerOptions,
2317
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2318
- ): Http2Server;
2743
+ export function createServer<
2744
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2745
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2746
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2747
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2748
+ >(
2749
+ options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2750
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2751
+ ): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>;
2319
2752
  /**
2320
- * Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
2753
+ * Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
2321
2754
  *
2322
2755
  * ```js
2323
- * const http2 = require('node:http2');
2324
- * const fs = require('node:fs');
2756
+ * import http2 from 'node:http2';
2757
+ * import fs from 'node:fs';
2325
2758
  *
2326
2759
  * const options = {
2327
2760
  * key: fs.readFileSync('server-key.pem'),
@@ -2347,15 +2780,20 @@ declare module "http2" {
2347
2780
  export function createSecureServer(
2348
2781
  onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2349
2782
  ): Http2SecureServer;
2350
- export function createSecureServer(
2351
- options: SecureServerOptions,
2352
- onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2353
- ): Http2SecureServer;
2783
+ export function createSecureServer<
2784
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2785
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2786
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2787
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2788
+ >(
2789
+ options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2790
+ onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void,
2791
+ ): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;
2354
2792
  /**
2355
2793
  * Returns a `ClientHttp2Session` instance.
2356
2794
  *
2357
2795
  * ```js
2358
- * const http2 = require('node:http2');
2796
+ * import http2 from 'node:http2';
2359
2797
  * const client = http2.connect('https://localhost:1234');
2360
2798
  *
2361
2799
  * // Use the client
@@ -2376,6 +2814,21 @@ declare module "http2" {
2376
2814
  options?: ClientSessionOptions | SecureClientSessionOptions,
2377
2815
  listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
2378
2816
  ): ClientHttp2Session;
2817
+ /**
2818
+ * Create an HTTP/2 server session from an existing socket.
2819
+ * @param socket A Duplex Stream
2820
+ * @param options Any `{@link createServer}` options can be provided.
2821
+ * @since v20.12.0
2822
+ */
2823
+ export function performServerHandshake<
2824
+ Http1Request extends typeof IncomingMessage = typeof IncomingMessage,
2825
+ Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,
2826
+ Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,
2827
+ Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,
2828
+ >(
2829
+ socket: stream.Duplex,
2830
+ options?: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
2831
+ ): ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>;
2379
2832
  }
2380
2833
  declare module "node:http2" {
2381
2834
  export * from "http2";