imran-dl 2.3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of imran-dl might be problematic. Click here for more details.

Files changed (229) hide show
  1. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  2. package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
  3. package/.cache/replit/__replit_disk_meta.json +1 -0
  4. package/.cache/replit/modules/nodejs-20:v32-20240401-269b323.res +1 -0
  5. package/.cache/replit/modules/replit:v8-20240329-787bc7d.res +1 -0
  6. package/.cache/replit/modules.stamp +0 -0
  7. package/.cache/replit/nix/env.json +1 -0
  8. package/.cache/typescript/5.0/node_modules/.package-lock.json +12 -0
  9. package/.cache/typescript/5.0/node_modules/types-registry/README.md +2 -0
  10. package/.cache/typescript/5.0/node_modules/types-registry/index.json +1 -0
  11. package/.cache/typescript/5.0/node_modules/types-registry/package.json +20 -0
  12. package/.cache/typescript/5.0/package.json +1 -0
  13. package/.cache/typescript/5.3/node_modules/.package-lock.json +114 -0
  14. package/.cache/typescript/5.3/node_modules/@types/cheerio/LICENSE +21 -0
  15. package/.cache/typescript/5.3/node_modules/@types/cheerio/README.md +15 -0
  16. package/.cache/typescript/5.3/node_modules/@types/cheerio/index.d.ts +318 -0
  17. package/.cache/typescript/5.3/node_modules/@types/cheerio/package.json +71 -0
  18. package/.cache/typescript/5.3/node_modules/@types/node/LICENSE +21 -0
  19. package/.cache/typescript/5.3/node_modules/@types/node/README.md +15 -0
  20. package/.cache/typescript/5.3/node_modules/@types/node/assert/strict.d.ts +8 -0
  21. package/.cache/typescript/5.3/node_modules/@types/node/assert.d.ts +996 -0
  22. package/.cache/typescript/5.3/node_modules/@types/node/async_hooks.d.ts +539 -0
  23. package/.cache/typescript/5.3/node_modules/@types/node/buffer.d.ts +2362 -0
  24. package/.cache/typescript/5.3/node_modules/@types/node/child_process.d.ts +1540 -0
  25. package/.cache/typescript/5.3/node_modules/@types/node/cluster.d.ts +432 -0
  26. package/.cache/typescript/5.3/node_modules/@types/node/console.d.ts +415 -0
  27. package/.cache/typescript/5.3/node_modules/@types/node/constants.d.ts +19 -0
  28. package/.cache/typescript/5.3/node_modules/@types/node/crypto.d.ts +4456 -0
  29. package/.cache/typescript/5.3/node_modules/@types/node/dgram.d.ts +586 -0
  30. package/.cache/typescript/5.3/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
  31. package/.cache/typescript/5.3/node_modules/@types/node/dns/promises.d.ts +425 -0
  32. package/.cache/typescript/5.3/node_modules/@types/node/dns.d.ts +809 -0
  33. package/.cache/typescript/5.3/node_modules/@types/node/dom-events.d.ts +122 -0
  34. package/.cache/typescript/5.3/node_modules/@types/node/domain.d.ts +170 -0
  35. package/.cache/typescript/5.3/node_modules/@types/node/events.d.ts +879 -0
  36. package/.cache/typescript/5.3/node_modules/@types/node/fs/promises.d.ts +1239 -0
  37. package/.cache/typescript/5.3/node_modules/@types/node/fs.d.ts +4291 -0
  38. package/.cache/typescript/5.3/node_modules/@types/node/globals.d.ts +385 -0
  39. package/.cache/typescript/5.3/node_modules/@types/node/globals.global.d.ts +1 -0
  40. package/.cache/typescript/5.3/node_modules/@types/node/http.d.ts +1888 -0
  41. package/.cache/typescript/5.3/node_modules/@types/node/http2.d.ts +2382 -0
  42. package/.cache/typescript/5.3/node_modules/@types/node/https.d.ts +550 -0
  43. package/.cache/typescript/5.3/node_modules/@types/node/index.d.ts +88 -0
  44. package/.cache/typescript/5.3/node_modules/@types/node/inspector.d.ts +2747 -0
  45. package/.cache/typescript/5.3/node_modules/@types/node/module.d.ts +301 -0
  46. package/.cache/typescript/5.3/node_modules/@types/node/net.d.ts +949 -0
  47. package/.cache/typescript/5.3/node_modules/@types/node/os.d.ts +478 -0
  48. package/.cache/typescript/5.3/node_modules/@types/node/package.json +230 -0
  49. package/.cache/typescript/5.3/node_modules/@types/node/path.d.ts +191 -0
  50. package/.cache/typescript/5.3/node_modules/@types/node/perf_hooks.d.ts +639 -0
  51. package/.cache/typescript/5.3/node_modules/@types/node/process.d.ts +1539 -0
  52. package/.cache/typescript/5.3/node_modules/@types/node/punycode.d.ts +117 -0
  53. package/.cache/typescript/5.3/node_modules/@types/node/querystring.d.ts +141 -0
  54. package/.cache/typescript/5.3/node_modules/@types/node/readline/promises.d.ts +150 -0
  55. package/.cache/typescript/5.3/node_modules/@types/node/readline.d.ts +539 -0
  56. package/.cache/typescript/5.3/node_modules/@types/node/repl.d.ts +430 -0
  57. package/.cache/typescript/5.3/node_modules/@types/node/stream/consumers.d.ts +12 -0
  58. package/.cache/typescript/5.3/node_modules/@types/node/stream/promises.d.ts +83 -0
  59. package/.cache/typescript/5.3/node_modules/@types/node/stream/web.d.ts +350 -0
  60. package/.cache/typescript/5.3/node_modules/@types/node/stream.d.ts +1701 -0
  61. package/.cache/typescript/5.3/node_modules/@types/node/string_decoder.d.ts +67 -0
  62. package/.cache/typescript/5.3/node_modules/@types/node/test.d.ts +1382 -0
  63. package/.cache/typescript/5.3/node_modules/@types/node/timers/promises.d.ts +93 -0
  64. package/.cache/typescript/5.3/node_modules/@types/node/timers.d.ts +240 -0
  65. package/.cache/typescript/5.3/node_modules/@types/node/tls.d.ts +1210 -0
  66. package/.cache/typescript/5.3/node_modules/@types/node/trace_events.d.ts +182 -0
  67. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  68. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/assert.d.ts +996 -0
  69. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/async_hooks.d.ts +539 -0
  70. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/buffer.d.ts +2362 -0
  71. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/child_process.d.ts +1540 -0
  72. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
  73. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/console.d.ts +415 -0
  74. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
  75. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/crypto.d.ts +4455 -0
  76. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
  77. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
  78. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dns/promises.d.ts +425 -0
  79. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
  80. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
  81. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  82. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/events.d.ts +879 -0
  83. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/fs/promises.d.ts +1239 -0
  84. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/fs.d.ts +4291 -0
  85. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/globals.d.ts +385 -0
  86. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  87. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/http.d.ts +1888 -0
  88. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/http2.d.ts +2382 -0
  89. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/https.d.ts +550 -0
  90. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  91. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/inspector.d.ts +2747 -0
  92. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/module.d.ts +301 -0
  93. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/net.d.ts +949 -0
  94. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/os.d.ts +478 -0
  95. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  96. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/perf_hooks.d.ts +639 -0
  97. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/process.d.ts +1539 -0
  98. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  99. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
  100. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/readline/promises.d.ts +150 -0
  101. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/readline.d.ts +539 -0
  102. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
  103. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  104. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
  105. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream/web.d.ts +350 -0
  106. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/stream.d.ts +1701 -0
  107. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  108. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/test.d.ts +1382 -0
  109. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  110. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/timers.d.ts +240 -0
  111. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/tls.d.ts +1210 -0
  112. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
  113. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
  114. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/url.d.ts +927 -0
  115. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/util.d.ts +2183 -0
  116. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/v8.d.ts +635 -0
  117. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/vm.d.ts +903 -0
  118. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  119. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/worker_threads.d.ts +691 -0
  120. package/.cache/typescript/5.3/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  121. package/.cache/typescript/5.3/node_modules/@types/node/tty.d.ts +208 -0
  122. package/.cache/typescript/5.3/node_modules/@types/node/url.d.ts +927 -0
  123. package/.cache/typescript/5.3/node_modules/@types/node/util.d.ts +2183 -0
  124. package/.cache/typescript/5.3/node_modules/@types/node/v8.d.ts +635 -0
  125. package/.cache/typescript/5.3/node_modules/@types/node/vm.d.ts +903 -0
  126. package/.cache/typescript/5.3/node_modules/@types/node/wasi.d.ts +158 -0
  127. package/.cache/typescript/5.3/node_modules/@types/node/worker_threads.d.ts +691 -0
  128. package/.cache/typescript/5.3/node_modules/@types/node/zlib.d.ts +517 -0
  129. package/.cache/typescript/5.3/node_modules/@types/node-fetch/LICENSE +21 -0
  130. package/.cache/typescript/5.3/node_modules/@types/node-fetch/README.md +15 -0
  131. package/.cache/typescript/5.3/node_modules/@types/node-fetch/externals.d.ts +32 -0
  132. package/.cache/typescript/5.3/node_modules/@types/node-fetch/index.d.ts +214 -0
  133. package/.cache/typescript/5.3/node_modules/@types/node-fetch/package.json +83 -0
  134. package/.cache/typescript/5.3/node_modules/@types/qs/LICENSE +21 -0
  135. package/.cache/typescript/5.3/node_modules/@types/qs/README.md +15 -0
  136. package/.cache/typescript/5.3/node_modules/@types/qs/index.d.ts +79 -0
  137. package/.cache/typescript/5.3/node_modules/@types/qs/package.json +65 -0
  138. package/.cache/typescript/5.3/node_modules/asynckit/LICENSE +21 -0
  139. package/.cache/typescript/5.3/node_modules/asynckit/README.md +233 -0
  140. package/.cache/typescript/5.3/node_modules/asynckit/bench.js +76 -0
  141. package/.cache/typescript/5.3/node_modules/asynckit/index.js +6 -0
  142. package/.cache/typescript/5.3/node_modules/asynckit/lib/abort.js +29 -0
  143. package/.cache/typescript/5.3/node_modules/asynckit/lib/async.js +34 -0
  144. package/.cache/typescript/5.3/node_modules/asynckit/lib/defer.js +26 -0
  145. package/.cache/typescript/5.3/node_modules/asynckit/lib/iterate.js +75 -0
  146. package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  147. package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_parallel.js +25 -0
  148. package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_serial.js +25 -0
  149. package/.cache/typescript/5.3/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  150. package/.cache/typescript/5.3/node_modules/asynckit/lib/state.js +37 -0
  151. package/.cache/typescript/5.3/node_modules/asynckit/lib/streamify.js +141 -0
  152. package/.cache/typescript/5.3/node_modules/asynckit/lib/terminator.js +29 -0
  153. package/.cache/typescript/5.3/node_modules/asynckit/package.json +63 -0
  154. package/.cache/typescript/5.3/node_modules/asynckit/parallel.js +43 -0
  155. package/.cache/typescript/5.3/node_modules/asynckit/serial.js +17 -0
  156. package/.cache/typescript/5.3/node_modules/asynckit/serialOrdered.js +75 -0
  157. package/.cache/typescript/5.3/node_modules/asynckit/stream.js +21 -0
  158. package/.cache/typescript/5.3/node_modules/combined-stream/License +19 -0
  159. package/.cache/typescript/5.3/node_modules/combined-stream/Readme.md +138 -0
  160. package/.cache/typescript/5.3/node_modules/combined-stream/lib/combined_stream.js +208 -0
  161. package/.cache/typescript/5.3/node_modules/combined-stream/package.json +25 -0
  162. package/.cache/typescript/5.3/node_modules/combined-stream/yarn.lock +17 -0
  163. package/.cache/typescript/5.3/node_modules/delayed-stream/License +19 -0
  164. package/.cache/typescript/5.3/node_modules/delayed-stream/Makefile +7 -0
  165. package/.cache/typescript/5.3/node_modules/delayed-stream/Readme.md +141 -0
  166. package/.cache/typescript/5.3/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  167. package/.cache/typescript/5.3/node_modules/delayed-stream/package.json +27 -0
  168. package/.cache/typescript/5.3/node_modules/form-data/License +19 -0
  169. package/.cache/typescript/5.3/node_modules/form-data/README.md.bak +358 -0
  170. package/.cache/typescript/5.3/node_modules/form-data/Readme.md +358 -0
  171. package/.cache/typescript/5.3/node_modules/form-data/index.d.ts +62 -0
  172. package/.cache/typescript/5.3/node_modules/form-data/lib/browser.js +2 -0
  173. package/.cache/typescript/5.3/node_modules/form-data/lib/form_data.js +501 -0
  174. package/.cache/typescript/5.3/node_modules/form-data/lib/populate.js +10 -0
  175. package/.cache/typescript/5.3/node_modules/form-data/package.json +68 -0
  176. package/.cache/typescript/5.3/node_modules/mime-db/HISTORY.md +507 -0
  177. package/.cache/typescript/5.3/node_modules/mime-db/LICENSE +23 -0
  178. package/.cache/typescript/5.3/node_modules/mime-db/README.md +100 -0
  179. package/.cache/typescript/5.3/node_modules/mime-db/db.json +8519 -0
  180. package/.cache/typescript/5.3/node_modules/mime-db/index.js +12 -0
  181. package/.cache/typescript/5.3/node_modules/mime-db/package.json +60 -0
  182. package/.cache/typescript/5.3/node_modules/mime-types/HISTORY.md +397 -0
  183. package/.cache/typescript/5.3/node_modules/mime-types/LICENSE +23 -0
  184. package/.cache/typescript/5.3/node_modules/mime-types/README.md +113 -0
  185. package/.cache/typescript/5.3/node_modules/mime-types/index.js +188 -0
  186. package/.cache/typescript/5.3/node_modules/mime-types/package.json +44 -0
  187. package/.cache/typescript/5.3/node_modules/types-registry/README.md +2 -0
  188. package/.cache/typescript/5.3/node_modules/types-registry/index.json +1 -0
  189. package/.cache/typescript/5.3/node_modules/types-registry/package.json +20 -0
  190. package/.cache/typescript/5.3/node_modules/undici-types/README.md +6 -0
  191. package/.cache/typescript/5.3/node_modules/undici-types/agent.d.ts +31 -0
  192. package/.cache/typescript/5.3/node_modules/undici-types/api.d.ts +43 -0
  193. package/.cache/typescript/5.3/node_modules/undici-types/balanced-pool.d.ts +18 -0
  194. package/.cache/typescript/5.3/node_modules/undici-types/cache.d.ts +36 -0
  195. package/.cache/typescript/5.3/node_modules/undici-types/client.d.ts +97 -0
  196. package/.cache/typescript/5.3/node_modules/undici-types/connector.d.ts +34 -0
  197. package/.cache/typescript/5.3/node_modules/undici-types/content-type.d.ts +21 -0
  198. package/.cache/typescript/5.3/node_modules/undici-types/cookies.d.ts +28 -0
  199. package/.cache/typescript/5.3/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  200. package/.cache/typescript/5.3/node_modules/undici-types/dispatcher.d.ts +241 -0
  201. package/.cache/typescript/5.3/node_modules/undici-types/errors.d.ts +128 -0
  202. package/.cache/typescript/5.3/node_modules/undici-types/fetch.d.ts +209 -0
  203. package/.cache/typescript/5.3/node_modules/undici-types/file.d.ts +39 -0
  204. package/.cache/typescript/5.3/node_modules/undici-types/filereader.d.ts +54 -0
  205. package/.cache/typescript/5.3/node_modules/undici-types/formdata.d.ts +108 -0
  206. package/.cache/typescript/5.3/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  207. package/.cache/typescript/5.3/node_modules/undici-types/global-origin.d.ts +7 -0
  208. package/.cache/typescript/5.3/node_modules/undici-types/handlers.d.ts +9 -0
  209. package/.cache/typescript/5.3/node_modules/undici-types/header.d.ts +4 -0
  210. package/.cache/typescript/5.3/node_modules/undici-types/index.d.ts +63 -0
  211. package/.cache/typescript/5.3/node_modules/undici-types/interceptors.d.ts +5 -0
  212. package/.cache/typescript/5.3/node_modules/undici-types/mock-agent.d.ts +50 -0
  213. package/.cache/typescript/5.3/node_modules/undici-types/mock-client.d.ts +25 -0
  214. package/.cache/typescript/5.3/node_modules/undici-types/mock-errors.d.ts +12 -0
  215. package/.cache/typescript/5.3/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  216. package/.cache/typescript/5.3/node_modules/undici-types/mock-pool.d.ts +25 -0
  217. package/.cache/typescript/5.3/node_modules/undici-types/package.json +55 -0
  218. package/.cache/typescript/5.3/node_modules/undici-types/patch.d.ts +71 -0
  219. package/.cache/typescript/5.3/node_modules/undici-types/pool-stats.d.ts +19 -0
  220. package/.cache/typescript/5.3/node_modules/undici-types/pool.d.ts +28 -0
  221. package/.cache/typescript/5.3/node_modules/undici-types/proxy-agent.d.ts +30 -0
  222. package/.cache/typescript/5.3/node_modules/undici-types/readable.d.ts +61 -0
  223. package/.cache/typescript/5.3/node_modules/undici-types/webidl.d.ts +220 -0
  224. package/.cache/typescript/5.3/node_modules/undici-types/websocket.d.ts +131 -0
  225. package/.cache/typescript/5.3/package.json +1 -0
  226. package/IMRAN/module.js +1 -0
  227. package/README.md +64 -0
  228. package/index.js +13 -0
  229. package/package.json +48 -0
@@ -0,0 +1,2382 @@
1
+ /**
2
+ * The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol.
3
+ * It can be accessed using:
4
+ *
5
+ * ```js
6
+ * const http2 = require('node:http2');
7
+ * ```
8
+ * @since v8.4.0
9
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/http2.js)
10
+ */
11
+ declare module "http2" {
12
+ import EventEmitter = require("node:events");
13
+ import * as fs from "node:fs";
14
+ import * as net from "node:net";
15
+ import * as stream from "node:stream";
16
+ import * as tls from "node:tls";
17
+ import * as url from "node:url";
18
+ import {
19
+ IncomingHttpHeaders as Http1IncomingHttpHeaders,
20
+ IncomingMessage,
21
+ OutgoingHttpHeaders,
22
+ ServerResponse,
23
+ } from "node:http";
24
+ export { OutgoingHttpHeaders } from "node:http";
25
+ export interface IncomingHttpStatusHeader {
26
+ ":status"?: number | undefined;
27
+ }
28
+ export interface IncomingHttpHeaders extends Http1IncomingHttpHeaders {
29
+ ":path"?: string | undefined;
30
+ ":method"?: string | undefined;
31
+ ":authority"?: string | undefined;
32
+ ":scheme"?: string | undefined;
33
+ }
34
+ // Http2Stream
35
+ export interface StreamPriorityOptions {
36
+ exclusive?: boolean | undefined;
37
+ parent?: number | undefined;
38
+ weight?: number | undefined;
39
+ silent?: boolean | undefined;
40
+ }
41
+ export interface StreamState {
42
+ localWindowSize?: number | undefined;
43
+ state?: number | undefined;
44
+ localClose?: number | undefined;
45
+ remoteClose?: number | undefined;
46
+ sumDependencyWeight?: number | undefined;
47
+ weight?: number | undefined;
48
+ }
49
+ export interface ServerStreamResponseOptions {
50
+ endStream?: boolean | undefined;
51
+ waitForTrailers?: boolean | undefined;
52
+ }
53
+ export interface StatOptions {
54
+ offset: number;
55
+ length: number;
56
+ }
57
+ 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;
60
+ waitForTrailers?: boolean | undefined;
61
+ offset?: number | undefined;
62
+ length?: number | undefined;
63
+ }
64
+ export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
65
+ onError?(err: NodeJS.ErrnoException): void;
66
+ }
67
+ export interface Http2Stream extends stream.Duplex {
68
+ /**
69
+ * Set to `true` if the `Http2Stream` instance was aborted abnormally. When set,
70
+ * the `'aborted'` event will have been emitted.
71
+ * @since v8.4.0
72
+ */
73
+ readonly aborted: boolean;
74
+ /**
75
+ * This property shows the number of characters currently buffered to be written.
76
+ * See `net.Socket.bufferSize` for details.
77
+ * @since v11.2.0, v10.16.0
78
+ */
79
+ readonly bufferSize: number;
80
+ /**
81
+ * Set to `true` if the `Http2Stream` instance has been closed.
82
+ * @since v9.4.0
83
+ */
84
+ readonly closed: boolean;
85
+ /**
86
+ * Set to `true` if the `Http2Stream` instance has been destroyed and is no longer
87
+ * usable.
88
+ * @since v8.4.0
89
+ */
90
+ readonly destroyed: boolean;
91
+ /**
92
+ * Set to `true` if the `END_STREAM` flag was set in the request or response
93
+ * HEADERS frame received, indicating that no additional data should be received
94
+ * and the readable side of the `Http2Stream` will be closed.
95
+ * @since v10.11.0
96
+ */
97
+ readonly endAfterHeaders: boolean;
98
+ /**
99
+ * The numeric stream identifier of this `Http2Stream` instance. Set to `undefined`if the stream identifier has not yet been assigned.
100
+ * @since v8.4.0
101
+ */
102
+ readonly id?: number | undefined;
103
+ /**
104
+ * Set to `true` if the `Http2Stream` instance has not yet been assigned a
105
+ * numeric stream identifier.
106
+ * @since v9.4.0
107
+ */
108
+ readonly pending: boolean;
109
+ /**
110
+ * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is
111
+ * 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.
113
+ * @since v8.4.0
114
+ */
115
+ readonly rstCode: number;
116
+ /**
117
+ * An object containing the outbound headers sent for this `Http2Stream`.
118
+ * @since v9.5.0
119
+ */
120
+ readonly sentHeaders: OutgoingHttpHeaders;
121
+ /**
122
+ * An array of objects containing the outbound informational (additional) headers
123
+ * sent for this `Http2Stream`.
124
+ * @since v9.5.0
125
+ */
126
+ readonly sentInfoHeaders?: OutgoingHttpHeaders[] | undefined;
127
+ /**
128
+ * An object containing the outbound trailers sent for this `HttpStream`.
129
+ * @since v9.5.0
130
+ */
131
+ readonly sentTrailers?: OutgoingHttpHeaders | undefined;
132
+ /**
133
+ * A reference to the `Http2Session` instance that owns this `Http2Stream`. The
134
+ * value will be `undefined` after the `Http2Stream` instance is destroyed.
135
+ * @since v8.4.0
136
+ */
137
+ readonly session: Http2Session | undefined;
138
+ /**
139
+ * Provides miscellaneous information about the current state of the`Http2Stream`.
140
+ *
141
+ * A current state of this `Http2Stream`.
142
+ * @since v8.4.0
143
+ */
144
+ readonly state: StreamState;
145
+ /**
146
+ * Closes the `Http2Stream` instance by sending an `RST_STREAM` frame to the
147
+ * connected HTTP/2 peer.
148
+ * @since v8.4.0
149
+ * @param [code=http2.constants.NGHTTP2_NO_ERROR] Unsigned 32-bit integer identifying the error code.
150
+ * @param callback An optional function registered to listen for the `'close'` event.
151
+ */
152
+ close(code?: number, callback?: () => void): void;
153
+ /**
154
+ * Updates the priority for this `Http2Stream` instance.
155
+ * @since v8.4.0
156
+ */
157
+ priority(options: StreamPriorityOptions): void;
158
+ /**
159
+ * ```js
160
+ * const http2 = require('node:http2');
161
+ * const client = http2.connect('http://example.org:8000');
162
+ * const { NGHTTP2_CANCEL } = http2.constants;
163
+ * const req = client.request({ ':path': '/' });
164
+ *
165
+ * // Cancel the stream if there's no activity after 5 seconds
166
+ * req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));
167
+ * ```
168
+ * @since v8.4.0
169
+ */
170
+ setTimeout(msecs: number, callback?: () => void): void;
171
+ /**
172
+ * Sends a trailing `HEADERS` frame to the connected HTTP/2 peer. This method
173
+ * will cause the `Http2Stream` to be immediately closed and must only be
174
+ * called after the `'wantTrailers'` event has been emitted. When sending a
175
+ * request or sending a response, the `options.waitForTrailers` option must be set
176
+ * in order to keep the `Http2Stream` open after the final `DATA` frame so that
177
+ * trailers can be sent.
178
+ *
179
+ * ```js
180
+ * const http2 = require('node:http2');
181
+ * const server = http2.createServer();
182
+ * server.on('stream', (stream) => {
183
+ * stream.respond(undefined, { waitForTrailers: true });
184
+ * stream.on('wantTrailers', () => {
185
+ * stream.sendTrailers({ xyz: 'abc' });
186
+ * });
187
+ * stream.end('Hello World');
188
+ * });
189
+ * ```
190
+ *
191
+ * The HTTP/1 specification forbids trailers from containing HTTP/2 pseudo-header
192
+ * fields (e.g. `':method'`, `':path'`, etc).
193
+ * @since v10.0.0
194
+ */
195
+ sendTrailers(headers: OutgoingHttpHeaders): void;
196
+ addListener(event: "aborted", listener: () => void): this;
197
+ addListener(event: "close", listener: () => void): this;
198
+ addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
199
+ addListener(event: "drain", listener: () => void): this;
200
+ addListener(event: "end", listener: () => void): this;
201
+ addListener(event: "error", listener: (err: Error) => void): this;
202
+ addListener(event: "finish", listener: () => void): this;
203
+ addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
204
+ addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
205
+ addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
206
+ addListener(event: "streamClosed", listener: (code: number) => void): this;
207
+ addListener(event: "timeout", listener: () => void): this;
208
+ addListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
209
+ addListener(event: "wantTrailers", listener: () => void): this;
210
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
211
+ emit(event: "aborted"): boolean;
212
+ emit(event: "close"): boolean;
213
+ emit(event: "data", chunk: Buffer | string): boolean;
214
+ emit(event: "drain"): boolean;
215
+ emit(event: "end"): boolean;
216
+ emit(event: "error", err: Error): boolean;
217
+ emit(event: "finish"): boolean;
218
+ emit(event: "frameError", frameType: number, errorCode: number): boolean;
219
+ emit(event: "pipe", src: stream.Readable): boolean;
220
+ emit(event: "unpipe", src: stream.Readable): boolean;
221
+ emit(event: "streamClosed", code: number): boolean;
222
+ emit(event: "timeout"): boolean;
223
+ emit(event: "trailers", trailers: IncomingHttpHeaders, flags: number): boolean;
224
+ emit(event: "wantTrailers"): boolean;
225
+ emit(event: string | symbol, ...args: any[]): boolean;
226
+ on(event: "aborted", listener: () => void): this;
227
+ on(event: "close", listener: () => void): this;
228
+ on(event: "data", listener: (chunk: Buffer | string) => void): this;
229
+ on(event: "drain", listener: () => void): this;
230
+ on(event: "end", listener: () => void): this;
231
+ on(event: "error", listener: (err: Error) => void): this;
232
+ on(event: "finish", listener: () => void): this;
233
+ on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
234
+ on(event: "pipe", listener: (src: stream.Readable) => void): this;
235
+ on(event: "unpipe", listener: (src: stream.Readable) => void): this;
236
+ on(event: "streamClosed", listener: (code: number) => void): this;
237
+ on(event: "timeout", listener: () => void): this;
238
+ on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
239
+ on(event: "wantTrailers", listener: () => void): this;
240
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
241
+ once(event: "aborted", listener: () => void): this;
242
+ once(event: "close", listener: () => void): this;
243
+ once(event: "data", listener: (chunk: Buffer | string) => void): this;
244
+ once(event: "drain", listener: () => void): this;
245
+ once(event: "end", listener: () => void): this;
246
+ once(event: "error", listener: (err: Error) => void): this;
247
+ once(event: "finish", listener: () => void): this;
248
+ once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
249
+ once(event: "pipe", listener: (src: stream.Readable) => void): this;
250
+ once(event: "unpipe", listener: (src: stream.Readable) => void): this;
251
+ once(event: "streamClosed", listener: (code: number) => void): this;
252
+ once(event: "timeout", listener: () => void): this;
253
+ once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
254
+ once(event: "wantTrailers", listener: () => void): this;
255
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
256
+ prependListener(event: "aborted", listener: () => void): this;
257
+ prependListener(event: "close", listener: () => void): this;
258
+ prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
259
+ prependListener(event: "drain", listener: () => void): this;
260
+ prependListener(event: "end", listener: () => void): this;
261
+ prependListener(event: "error", listener: (err: Error) => void): this;
262
+ prependListener(event: "finish", listener: () => void): this;
263
+ prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
264
+ prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
265
+ prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
266
+ prependListener(event: "streamClosed", listener: (code: number) => void): this;
267
+ prependListener(event: "timeout", listener: () => void): this;
268
+ prependListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
269
+ prependListener(event: "wantTrailers", listener: () => void): this;
270
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
271
+ prependOnceListener(event: "aborted", listener: () => void): this;
272
+ prependOnceListener(event: "close", listener: () => void): this;
273
+ prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
274
+ prependOnceListener(event: "drain", listener: () => void): this;
275
+ prependOnceListener(event: "end", listener: () => void): this;
276
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
277
+ prependOnceListener(event: "finish", listener: () => void): this;
278
+ prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
279
+ prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
280
+ prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
281
+ prependOnceListener(event: "streamClosed", listener: (code: number) => void): this;
282
+ prependOnceListener(event: "timeout", listener: () => void): this;
283
+ prependOnceListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
284
+ prependOnceListener(event: "wantTrailers", listener: () => void): this;
285
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
286
+ }
287
+ export interface ClientHttp2Stream extends Http2Stream {
288
+ addListener(event: "continue", listener: () => {}): this;
289
+ addListener(
290
+ event: "headers",
291
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
292
+ ): this;
293
+ addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
294
+ addListener(
295
+ event: "response",
296
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
297
+ ): this;
298
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
299
+ emit(event: "continue"): boolean;
300
+ emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
301
+ emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean;
302
+ emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
303
+ emit(event: string | symbol, ...args: any[]): boolean;
304
+ on(event: "continue", listener: () => {}): this;
305
+ on(
306
+ event: "headers",
307
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
308
+ ): this;
309
+ on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
310
+ on(
311
+ event: "response",
312
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
313
+ ): this;
314
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
315
+ once(event: "continue", listener: () => {}): this;
316
+ once(
317
+ event: "headers",
318
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
319
+ ): this;
320
+ once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
321
+ once(
322
+ event: "response",
323
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
324
+ ): this;
325
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
326
+ prependListener(event: "continue", listener: () => {}): this;
327
+ prependListener(
328
+ event: "headers",
329
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
330
+ ): this;
331
+ prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
332
+ prependListener(
333
+ event: "response",
334
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
335
+ ): this;
336
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
337
+ prependOnceListener(event: "continue", listener: () => {}): this;
338
+ prependOnceListener(
339
+ event: "headers",
340
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
341
+ ): this;
342
+ prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
343
+ prependOnceListener(
344
+ event: "response",
345
+ listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void,
346
+ ): this;
347
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
348
+ }
349
+ export interface ServerHttp2Stream extends Http2Stream {
350
+ /**
351
+ * True if headers were sent, false otherwise (read-only).
352
+ * @since v8.4.0
353
+ */
354
+ readonly headersSent: boolean;
355
+ /**
356
+ * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote
357
+ * 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`.
359
+ * @since v8.4.0
360
+ */
361
+ readonly pushAllowed: boolean;
362
+ /**
363
+ * Sends an additional informational `HEADERS` frame to the connected HTTP/2 peer.
364
+ * @since v8.4.0
365
+ */
366
+ additionalHeaders(headers: OutgoingHttpHeaders): void;
367
+ /**
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.
369
+ *
370
+ * ```js
371
+ * const http2 = require('node:http2');
372
+ * const server = http2.createServer();
373
+ * server.on('stream', (stream) => {
374
+ * stream.respond({ ':status': 200 });
375
+ * stream.pushStream({ ':path': '/' }, (err, pushStream, headers) => {
376
+ * if (err) throw err;
377
+ * pushStream.respond({ ':status': 200 });
378
+ * pushStream.end('some pushed data');
379
+ * });
380
+ * stream.end('some data');
381
+ * });
382
+ * ```
383
+ *
384
+ * 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.
386
+ *
387
+ * Calling `http2stream.pushStream()` from within a pushed stream is not permitted
388
+ * and will throw an error.
389
+ * @since v8.4.0
390
+ * @param callback Callback that is called once the push stream has been initiated.
391
+ */
392
+ pushStream(
393
+ headers: OutgoingHttpHeaders,
394
+ callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void,
395
+ ): void;
396
+ pushStream(
397
+ headers: OutgoingHttpHeaders,
398
+ options?: StreamPriorityOptions,
399
+ callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void,
400
+ ): void;
401
+ /**
402
+ * ```js
403
+ * const http2 = require('node:http2');
404
+ * const server = http2.createServer();
405
+ * server.on('stream', (stream) => {
406
+ * stream.respond({ ':status': 200 });
407
+ * stream.end('some data');
408
+ * });
409
+ * ```
410
+ *
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.
414
+ *
415
+ * 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`.
417
+ *
418
+ * ```js
419
+ * const http2 = require('node:http2');
420
+ * const server = http2.createServer();
421
+ * server.on('stream', (stream) => {
422
+ * stream.respond({ ':status': 200 }, { waitForTrailers: true });
423
+ * stream.on('wantTrailers', () => {
424
+ * stream.sendTrailers({ ABC: 'some value to send' });
425
+ * });
426
+ * stream.end('some data');
427
+ * });
428
+ * ```
429
+ * @since v8.4.0
430
+ */
431
+ respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
432
+ /**
433
+ * Initiates a response whose data is read from the given file descriptor. No
434
+ * validation is performed on the given file descriptor. If an error occurs while
435
+ * attempting to read data using the file descriptor, the `Http2Stream` will be
436
+ * closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.
437
+ *
438
+ * When used, the `Http2Stream` object's `Duplex` interface will be closed
439
+ * automatically.
440
+ *
441
+ * ```js
442
+ * const http2 = require('node:http2');
443
+ * const fs = require('node:fs');
444
+ *
445
+ * const server = http2.createServer();
446
+ * server.on('stream', (stream) => {
447
+ * const fd = fs.openSync('/some/file', 'r');
448
+ *
449
+ * const stat = fs.fstatSync(fd);
450
+ * const headers = {
451
+ * 'content-length': stat.size,
452
+ * 'last-modified': stat.mtime.toUTCString(),
453
+ * 'content-type': 'text/plain; charset=utf-8',
454
+ * };
455
+ * stream.respondWithFD(fd, headers);
456
+ * stream.on('close', () => fs.closeSync(fd));
457
+ * });
458
+ * ```
459
+ *
460
+ * The optional `options.statCheck` function may be specified to give user code
461
+ * 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.
464
+ *
465
+ * The `offset` and `length` options may be used to limit the response to a
466
+ * specific range subset. This can be used, for instance, to support HTTP Range
467
+ * requests.
468
+ *
469
+ * The file descriptor or `FileHandle` is not closed when the stream is closed,
470
+ * so it will need to be closed manually once it is no longer needed.
471
+ * Using the same file descriptor concurrently for multiple streams
472
+ * is not supported and may result in data loss. Re-using a file descriptor
473
+ * after a stream has finished is supported.
474
+ *
475
+ * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
476
+ * will be emitted immediately after queuing the last chunk of payload data to be
477
+ * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing
478
+ * header fields to the peer.
479
+ *
480
+ * 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`.
482
+ *
483
+ * ```js
484
+ * const http2 = require('node:http2');
485
+ * const fs = require('node:fs');
486
+ *
487
+ * const server = http2.createServer();
488
+ * server.on('stream', (stream) => {
489
+ * const fd = fs.openSync('/some/file', 'r');
490
+ *
491
+ * const stat = fs.fstatSync(fd);
492
+ * const headers = {
493
+ * 'content-length': stat.size,
494
+ * 'last-modified': stat.mtime.toUTCString(),
495
+ * 'content-type': 'text/plain; charset=utf-8',
496
+ * };
497
+ * stream.respondWithFD(fd, headers, { waitForTrailers: true });
498
+ * stream.on('wantTrailers', () => {
499
+ * stream.sendTrailers({ ABC: 'some value to send' });
500
+ * });
501
+ *
502
+ * stream.on('close', () => fs.closeSync(fd));
503
+ * });
504
+ * ```
505
+ * @since v8.4.0
506
+ * @param fd A readable file descriptor.
507
+ */
508
+ respondWithFD(
509
+ fd: number | fs.promises.FileHandle,
510
+ headers?: OutgoingHttpHeaders,
511
+ options?: ServerStreamFileResponseOptions,
512
+ ): void;
513
+ /**
514
+ * Sends a regular file as the response. The `path` must specify a regular file
515
+ * or an `'error'` event will be emitted on the `Http2Stream` object.
516
+ *
517
+ * When used, the `Http2Stream` object's `Duplex` interface will be closed
518
+ * automatically.
519
+ *
520
+ * The optional `options.statCheck` function may be specified to give user code
521
+ * an opportunity to set additional content headers based on the `fs.Stat` details
522
+ * of the given file:
523
+ *
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.
527
+ *
528
+ * Example using a file path:
529
+ *
530
+ * ```js
531
+ * const http2 = require('node:http2');
532
+ * const server = http2.createServer();
533
+ * server.on('stream', (stream) => {
534
+ * function statCheck(stat, headers) {
535
+ * headers['last-modified'] = stat.mtime.toUTCString();
536
+ * }
537
+ *
538
+ * function onError(err) {
539
+ * // stream.respond() can throw if the stream has been destroyed by
540
+ * // the other side.
541
+ * try {
542
+ * if (err.code === 'ENOENT') {
543
+ * stream.respond({ ':status': 404 });
544
+ * } else {
545
+ * stream.respond({ ':status': 500 });
546
+ * }
547
+ * } catch (err) {
548
+ * // Perform actual error handling.
549
+ * console.error(err);
550
+ * }
551
+ * stream.end();
552
+ * }
553
+ *
554
+ * stream.respondWithFile('/some/file',
555
+ * { 'content-type': 'text/plain; charset=utf-8' },
556
+ * { statCheck, onError });
557
+ * });
558
+ * ```
559
+ *
560
+ * The `options.statCheck` function may also be used to cancel the send operation
561
+ * 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:
563
+ *
564
+ * ```js
565
+ * const http2 = require('node:http2');
566
+ * const server = http2.createServer();
567
+ * server.on('stream', (stream) => {
568
+ * function statCheck(stat, headers) {
569
+ * // Check the stat here...
570
+ * stream.respond({ ':status': 304 });
571
+ * return false; // Cancel the send operation
572
+ * }
573
+ * stream.respondWithFile('/some/file',
574
+ * { 'content-type': 'text/plain; charset=utf-8' },
575
+ * { statCheck });
576
+ * });
577
+ * ```
578
+ *
579
+ * The `content-length` header field will be automatically set.
580
+ *
581
+ * The `offset` and `length` options may be used to limit the response to a
582
+ * specific range subset. This can be used, for instance, to support HTTP Range
583
+ * requests.
584
+ *
585
+ * The `options.onError` function may also be used to handle all the errors
586
+ * that could happen before the delivery of the file is initiated. The
587
+ * default behavior is to destroy the stream.
588
+ *
589
+ * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
590
+ * will be emitted immediately after queuing the last chunk of payload data to be
591
+ * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing
592
+ * header fields to the peer.
593
+ *
594
+ * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
595
+ * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
596
+ *
597
+ * ```js
598
+ * const http2 = require('node:http2');
599
+ * const server = http2.createServer();
600
+ * server.on('stream', (stream) => {
601
+ * stream.respondWithFile('/some/file',
602
+ * { 'content-type': 'text/plain; charset=utf-8' },
603
+ * { waitForTrailers: true });
604
+ * stream.on('wantTrailers', () => {
605
+ * stream.sendTrailers({ ABC: 'some value to send' });
606
+ * });
607
+ * });
608
+ * ```
609
+ * @since v8.4.0
610
+ */
611
+ respondWithFile(
612
+ path: string,
613
+ headers?: OutgoingHttpHeaders,
614
+ options?: ServerStreamFileResponseOptionsWithError,
615
+ ): void;
616
+ }
617
+ // Http2Session
618
+ export interface Settings {
619
+ headerTableSize?: number | undefined;
620
+ enablePush?: boolean | undefined;
621
+ initialWindowSize?: number | undefined;
622
+ maxFrameSize?: number | undefined;
623
+ maxConcurrentStreams?: number | undefined;
624
+ maxHeaderListSize?: number | undefined;
625
+ enableConnectProtocol?: boolean | undefined;
626
+ }
627
+ export interface ClientSessionRequestOptions {
628
+ endStream?: boolean | undefined;
629
+ exclusive?: boolean | undefined;
630
+ parent?: number | undefined;
631
+ weight?: number | undefined;
632
+ waitForTrailers?: boolean | undefined;
633
+ signal?: AbortSignal | undefined;
634
+ }
635
+ export interface SessionState {
636
+ effectiveLocalWindowSize?: number | undefined;
637
+ effectiveRecvDataLength?: number | undefined;
638
+ nextStreamID?: number | undefined;
639
+ localWindowSize?: number | undefined;
640
+ lastProcStreamID?: number | undefined;
641
+ remoteWindowSize?: number | undefined;
642
+ outboundQueueSize?: number | undefined;
643
+ deflateDynamicTableSize?: number | undefined;
644
+ inflateDynamicTableSize?: number | undefined;
645
+ }
646
+ export interface Http2Session extends EventEmitter {
647
+ /**
648
+ * Value will be `undefined` if the `Http2Session` is not yet connected to a
649
+ * 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.
651
+ * @since v9.4.0
652
+ */
653
+ readonly alpnProtocol?: string | undefined;
654
+ /**
655
+ * Will be `true` if this `Http2Session` instance has been closed, otherwise`false`.
656
+ * @since v9.4.0
657
+ */
658
+ readonly closed: boolean;
659
+ /**
660
+ * 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.
662
+ * @since v10.0.0
663
+ */
664
+ readonly connecting: boolean;
665
+ /**
666
+ * Will be `true` if this `Http2Session` instance has been destroyed and must no
667
+ * longer be used, otherwise `false`.
668
+ * @since v8.4.0
669
+ */
670
+ readonly destroyed: boolean;
671
+ /**
672
+ * Value is `undefined` if the `Http2Session` session socket has not yet been
673
+ * connected, `true` if the `Http2Session` is connected with a `TLSSocket`,
674
+ * and `false` if the `Http2Session` is connected to any other kind of socket
675
+ * or stream.
676
+ * @since v9.4.0
677
+ */
678
+ readonly encrypted?: boolean | undefined;
679
+ /**
680
+ * A prototype-less object describing the current local settings of this`Http2Session`. The local settings are local to _this_`Http2Session` instance.
681
+ * @since v8.4.0
682
+ */
683
+ readonly localSettings: Settings;
684
+ /**
685
+ * If the `Http2Session` is connected to a `TLSSocket`, the `originSet` property
686
+ * will return an `Array` of origins for which the `Http2Session` may be
687
+ * considered authoritative.
688
+ *
689
+ * The `originSet` property is only available when using a secure TLS connection.
690
+ * @since v9.4.0
691
+ */
692
+ readonly originSet?: string[] | undefined;
693
+ /**
694
+ * 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.
696
+ * @since v8.4.0
697
+ */
698
+ readonly pendingSettingsAck: boolean;
699
+ /**
700
+ * A prototype-less object describing the current remote settings of this`Http2Session`. The remote settings are set by the _connected_ HTTP/2 peer.
701
+ * @since v8.4.0
702
+ */
703
+ readonly remoteSettings: Settings;
704
+ /**
705
+ * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
706
+ * limits available methods to ones safe to use with HTTP/2.
707
+ *
708
+ * `destroy`, `emit`, `end`, `pause`, `read`, `resume`, and `write` will throw
709
+ * an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for more information.
710
+ *
711
+ * `setTimeout` method will be called on this `Http2Session`.
712
+ *
713
+ * All other interactions will be routed directly to the socket.
714
+ * @since v8.4.0
715
+ */
716
+ readonly socket: net.Socket | tls.TLSSocket;
717
+ /**
718
+ * Provides miscellaneous information about the current state of the`Http2Session`.
719
+ *
720
+ * An object describing the current status of this `Http2Session`.
721
+ * @since v8.4.0
722
+ */
723
+ readonly state: SessionState;
724
+ /**
725
+ * The `http2session.type` will be equal to`http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a
726
+ * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a
727
+ * client.
728
+ * @since v8.4.0
729
+ */
730
+ readonly type: number;
731
+ /**
732
+ * Gracefully closes the `Http2Session`, allowing any existing streams to
733
+ * complete on their own and preventing new `Http2Stream` instances from being
734
+ * created. Once closed, `http2session.destroy()`_might_ be called if there
735
+ * are no open `Http2Stream` instances.
736
+ *
737
+ * If specified, the `callback` function is registered as a handler for the`'close'` event.
738
+ * @since v9.4.0
739
+ */
740
+ close(callback?: () => void): void;
741
+ /**
742
+ * Immediately terminates the `Http2Session` and the associated `net.Socket` or`tls.TLSSocket`.
743
+ *
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.
745
+ *
746
+ * If there are any remaining open `Http2Streams` associated with the`Http2Session`, those will also be destroyed.
747
+ * @since v8.4.0
748
+ * @param error An `Error` object if the `Http2Session` is being destroyed due to an error.
749
+ * @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`.
750
+ */
751
+ destroy(error?: Error, code?: number): void;
752
+ /**
753
+ * Transmits a `GOAWAY` frame to the connected peer _without_ shutting down the`Http2Session`.
754
+ * @since v9.4.0
755
+ * @param code An HTTP/2 error code
756
+ * @param lastStreamID The numeric ID of the last processed `Http2Stream`
757
+ * @param opaqueData A `TypedArray` or `DataView` instance containing additional data to be carried within the `GOAWAY` frame.
758
+ */
759
+ goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;
760
+ /**
761
+ * 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.
763
+ *
764
+ * The maximum number of outstanding (unacknowledged) pings is determined by the`maxOutstandingPings` configuration option. The default maximum is 10.
765
+ *
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
767
+ * returned with the ping acknowledgment.
768
+ *
769
+ * The callback will be invoked with three arguments: an error argument that will
770
+ * be `null` if the `PING` was successfully acknowledged, a `duration` argument
771
+ * 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.
773
+ *
774
+ * ```js
775
+ * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
776
+ * if (!err) {
777
+ * console.log(`Ping acknowledged in ${duration} milliseconds`);
778
+ * console.log(`With payload '${payload.toString()}'`);
779
+ * }
780
+ * });
781
+ * ```
782
+ *
783
+ * If the `payload` argument is not specified, the default payload will be the
784
+ * 64-bit timestamp (little endian) marking the start of the `PING` duration.
785
+ * @since v8.9.3
786
+ * @param payload Optional ping payload.
787
+ */
788
+ ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
789
+ ping(
790
+ payload: NodeJS.ArrayBufferView,
791
+ callback: (err: Error | null, duration: number, payload: Buffer) => void,
792
+ ): boolean;
793
+ /**
794
+ * Calls `ref()` on this `Http2Session`instance's underlying `net.Socket`.
795
+ * @since v9.4.0
796
+ */
797
+ ref(): void;
798
+ /**
799
+ * Sets the local endpoint's window size.
800
+ * The `windowSize` is the total window size to set, not
801
+ * the delta.
802
+ *
803
+ * ```js
804
+ * const http2 = require('node:http2');
805
+ *
806
+ * const server = http2.createServer();
807
+ * const expectedWindowSize = 2 ** 20;
808
+ * server.on('connect', (session) => {
809
+ *
810
+ * // Set local window size to be 2 ** 20
811
+ * session.setLocalWindowSize(expectedWindowSize);
812
+ * });
813
+ * ```
814
+ * @since v15.3.0, v14.18.0
815
+ */
816
+ setLocalWindowSize(windowSize: number): void;
817
+ /**
818
+ * Used to set a callback function that is called when there is no activity on
819
+ * the `Http2Session` after `msecs` milliseconds. The given `callback` is
820
+ * registered as a listener on the `'timeout'` event.
821
+ * @since v8.4.0
822
+ */
823
+ setTimeout(msecs: number, callback?: () => void): void;
824
+ /**
825
+ * Updates the current local settings for this `Http2Session` and sends a new`SETTINGS` frame to the connected HTTP/2 peer.
826
+ *
827
+ * Once called, the `http2session.pendingSettingsAck` property will be `true`while the session is waiting for the remote peer to acknowledge the new
828
+ * settings.
829
+ *
830
+ * The new settings will not become effective until the `SETTINGS` acknowledgment
831
+ * is received and the `'localSettings'` event is emitted. It is possible to send
832
+ * multiple `SETTINGS` frames while acknowledgment is still pending.
833
+ * @since v8.4.0
834
+ * @param callback Callback that is called once the session is connected or right away if the session is already connected.
835
+ */
836
+ settings(
837
+ settings: Settings,
838
+ callback?: (err: Error | null, settings: Settings, duration: number) => void,
839
+ ): void;
840
+ /**
841
+ * Calls `unref()` on this `Http2Session`instance's underlying `net.Socket`.
842
+ * @since v9.4.0
843
+ */
844
+ unref(): void;
845
+ addListener(event: "close", listener: () => void): this;
846
+ addListener(event: "error", listener: (err: Error) => void): this;
847
+ addListener(
848
+ event: "frameError",
849
+ listener: (frameType: number, errorCode: number, streamID: number) => void,
850
+ ): this;
851
+ addListener(
852
+ event: "goaway",
853
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
854
+ ): this;
855
+ addListener(event: "localSettings", listener: (settings: Settings) => void): this;
856
+ addListener(event: "ping", listener: () => void): this;
857
+ addListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
858
+ addListener(event: "timeout", listener: () => void): this;
859
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
860
+ emit(event: "close"): boolean;
861
+ 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;
864
+ emit(event: "localSettings", settings: Settings): boolean;
865
+ emit(event: "ping"): boolean;
866
+ emit(event: "remoteSettings", settings: Settings): boolean;
867
+ emit(event: "timeout"): boolean;
868
+ emit(event: string | symbol, ...args: any[]): boolean;
869
+ on(event: "close", listener: () => void): this;
870
+ 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;
873
+ on(event: "localSettings", listener: (settings: Settings) => void): this;
874
+ on(event: "ping", listener: () => void): this;
875
+ on(event: "remoteSettings", listener: (settings: Settings) => void): this;
876
+ on(event: "timeout", listener: () => void): this;
877
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
878
+ once(event: "close", listener: () => void): this;
879
+ 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;
882
+ once(event: "localSettings", listener: (settings: Settings) => void): this;
883
+ once(event: "ping", listener: () => void): this;
884
+ once(event: "remoteSettings", listener: (settings: Settings) => void): this;
885
+ once(event: "timeout", listener: () => void): this;
886
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
887
+ prependListener(event: "close", listener: () => void): this;
888
+ prependListener(event: "error", listener: (err: Error) => void): this;
889
+ prependListener(
890
+ event: "frameError",
891
+ listener: (frameType: number, errorCode: number, streamID: number) => void,
892
+ ): this;
893
+ prependListener(
894
+ event: "goaway",
895
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
896
+ ): this;
897
+ prependListener(event: "localSettings", listener: (settings: Settings) => void): this;
898
+ prependListener(event: "ping", listener: () => void): this;
899
+ prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
900
+ prependListener(event: "timeout", listener: () => void): this;
901
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
902
+ prependOnceListener(event: "close", listener: () => void): this;
903
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
904
+ prependOnceListener(
905
+ event: "frameError",
906
+ listener: (frameType: number, errorCode: number, streamID: number) => void,
907
+ ): this;
908
+ prependOnceListener(
909
+ event: "goaway",
910
+ listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,
911
+ ): this;
912
+ prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;
913
+ prependOnceListener(event: "ping", listener: () => void): this;
914
+ prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
915
+ prependOnceListener(event: "timeout", listener: () => void): this;
916
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
917
+ }
918
+ export interface ClientHttp2Session extends Http2Session {
919
+ /**
920
+ * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
921
+ * HTTP/2 request to the connected server.
922
+ *
923
+ * When a `ClientHttp2Session` is first created, the socket may not yet be
924
+ * connected. if `clienthttp2session.request()` is called during this time, the
925
+ * 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.
927
+ *
928
+ * This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
929
+ *
930
+ * ```js
931
+ * const http2 = require('node:http2');
932
+ * const clientSession = http2.connect('https://localhost:1234');
933
+ * const {
934
+ * HTTP2_HEADER_PATH,
935
+ * HTTP2_HEADER_STATUS,
936
+ * } = http2.constants;
937
+ *
938
+ * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
939
+ * req.on('response', (headers) => {
940
+ * console.log(headers[HTTP2_HEADER_STATUS]);
941
+ * req.on('data', (chunk) => { // .. });
942
+ * req.on('end', () => { // .. });
943
+ * });
944
+ * ```
945
+ *
946
+ * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event
947
+ * is emitted immediately after queuing the last chunk of payload data to be sent.
948
+ * The `http2stream.sendTrailers()` method can then be called to send trailing
949
+ * headers to the peer.
950
+ *
951
+ * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically
952
+ * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.
953
+ *
954
+ * When `options.signal` is set with an `AbortSignal` and then `abort` on the
955
+ * corresponding `AbortController` is called, the request will emit an `'error'`event with an `AbortError` error.
956
+ *
957
+ * The `:method` and `:path` pseudo-headers are not specified within `headers`,
958
+ * they respectively default to:
959
+ *
960
+ * * `:method` \= `'GET'`
961
+ * * `:path` \= `/`
962
+ * @since v8.4.0
963
+ */
964
+ request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
965
+ addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
966
+ addListener(event: "origin", listener: (origins: string[]) => void): this;
967
+ addListener(
968
+ event: "connect",
969
+ listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
970
+ ): this;
971
+ addListener(
972
+ event: "stream",
973
+ listener: (
974
+ stream: ClientHttp2Stream,
975
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
976
+ flags: number,
977
+ ) => void,
978
+ ): this;
979
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
980
+ emit(event: "altsvc", alt: string, origin: string, stream: number): boolean;
981
+ emit(event: "origin", origins: readonly string[]): boolean;
982
+ emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
983
+ emit(
984
+ event: "stream",
985
+ stream: ClientHttp2Stream,
986
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
987
+ flags: number,
988
+ ): boolean;
989
+ emit(event: string | symbol, ...args: any[]): boolean;
990
+ on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
991
+ on(event: "origin", listener: (origins: string[]) => void): this;
992
+ on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
993
+ on(
994
+ event: "stream",
995
+ listener: (
996
+ stream: ClientHttp2Stream,
997
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
998
+ flags: number,
999
+ ) => void,
1000
+ ): this;
1001
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1002
+ once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
1003
+ once(event: "origin", listener: (origins: string[]) => void): this;
1004
+ once(
1005
+ event: "connect",
1006
+ listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1007
+ ): this;
1008
+ once(
1009
+ event: "stream",
1010
+ listener: (
1011
+ stream: ClientHttp2Stream,
1012
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1013
+ flags: number,
1014
+ ) => void,
1015
+ ): this;
1016
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1017
+ prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
1018
+ prependListener(event: "origin", listener: (origins: string[]) => void): this;
1019
+ prependListener(
1020
+ event: "connect",
1021
+ listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1022
+ ): this;
1023
+ prependListener(
1024
+ event: "stream",
1025
+ listener: (
1026
+ stream: ClientHttp2Stream,
1027
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1028
+ flags: number,
1029
+ ) => void,
1030
+ ): this;
1031
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1032
+ prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
1033
+ prependOnceListener(event: "origin", listener: (origins: string[]) => void): this;
1034
+ prependOnceListener(
1035
+ event: "connect",
1036
+ listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1037
+ ): this;
1038
+ prependOnceListener(
1039
+ event: "stream",
1040
+ listener: (
1041
+ stream: ClientHttp2Stream,
1042
+ headers: IncomingHttpHeaders & IncomingHttpStatusHeader,
1043
+ flags: number,
1044
+ ) => void,
1045
+ ): this;
1046
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1047
+ }
1048
+ export interface AlternativeServiceOptions {
1049
+ origin: number | string | url.URL;
1050
+ }
1051
+ export interface ServerHttp2Session extends Http2Session {
1052
+ readonly server: Http2Server | Http2SecureServer;
1053
+ /**
1054
+ * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.
1055
+ *
1056
+ * ```js
1057
+ * const http2 = require('node:http2');
1058
+ *
1059
+ * const server = http2.createServer();
1060
+ * server.on('session', (session) => {
1061
+ * // Set altsvc for origin https://example.org:80
1062
+ * session.altsvc('h2=":8000"', 'https://example.org:80');
1063
+ * });
1064
+ *
1065
+ * server.on('stream', (stream) => {
1066
+ * // Set altsvc for a specific stream
1067
+ * stream.session.altsvc('h2=":8000"', stream.id);
1068
+ * });
1069
+ * ```
1070
+ *
1071
+ * Sending an `ALTSVC` frame with a specific stream ID indicates that the alternate
1072
+ * service is associated with the origin of the given `Http2Stream`.
1073
+ *
1074
+ * The `alt` and origin string _must_ contain only ASCII bytes and are
1075
+ * strictly interpreted as a sequence of ASCII bytes. The special value `'clear'`may be passed to clear any previously set alternative service for a given
1076
+ * domain.
1077
+ *
1078
+ * When a string is passed for the `originOrStream` argument, it will be parsed as
1079
+ * a URL and the origin will be derived. For instance, the origin for the
1080
+ * HTTP URL `'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given string
1081
+ * cannot be parsed as a URL or if a valid origin cannot be derived.
1082
+ *
1083
+ * A `URL` object, or any object with an `origin` property, may be passed as`originOrStream`, in which case the value of the `origin` property will be
1084
+ * used. The value of the `origin` property _must_ be a properly serialized
1085
+ * ASCII origin.
1086
+ * @since v9.4.0
1087
+ * @param alt A description of the alternative service configuration as defined by `RFC 7838`.
1088
+ * @param originOrStream Either a URL string specifying the origin (or an `Object` with an `origin` property) or the numeric identifier of an active `Http2Stream` as given by the
1089
+ * `http2stream.id` property.
1090
+ */
1091
+ altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void;
1092
+ /**
1093
+ * Submits an `ORIGIN` frame (as defined by [RFC 8336](https://tools.ietf.org/html/rfc8336)) to the connected client
1094
+ * to advertise the set of origins for which the server is capable of providing
1095
+ * authoritative responses.
1096
+ *
1097
+ * ```js
1098
+ * const http2 = require('node:http2');
1099
+ * const options = getSecureOptionsSomehow();
1100
+ * const server = http2.createSecureServer(options);
1101
+ * server.on('stream', (stream) => {
1102
+ * stream.respond();
1103
+ * stream.end('ok');
1104
+ * });
1105
+ * server.on('session', (session) => {
1106
+ * session.origin('https://example.com', 'https://example.org');
1107
+ * });
1108
+ * ```
1109
+ *
1110
+ * 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
1112
+ * string
1113
+ * cannot be parsed as a URL or if a valid origin cannot be derived.
1114
+ *
1115
+ * A `URL` object, or any object with an `origin` property, may be passed as
1116
+ * an `origin`, in which case the value of the `origin` property will be
1117
+ * used. The value of the `origin` property _must_ be a properly serialized
1118
+ * ASCII origin.
1119
+ *
1120
+ * Alternatively, the `origins` option may be used when creating a new HTTP/2
1121
+ * server using the `http2.createSecureServer()` method:
1122
+ *
1123
+ * ```js
1124
+ * const http2 = require('node:http2');
1125
+ * const options = getSecureOptionsSomehow();
1126
+ * options.origins = ['https://example.com', 'https://example.org'];
1127
+ * const server = http2.createSecureServer(options);
1128
+ * server.on('stream', (stream) => {
1129
+ * stream.respond();
1130
+ * stream.end('ok');
1131
+ * });
1132
+ * ```
1133
+ * @since v10.12.0
1134
+ * @param origins One or more URL Strings passed as separate arguments.
1135
+ */
1136
+ origin(
1137
+ ...origins: Array<
1138
+ | string
1139
+ | url.URL
1140
+ | {
1141
+ origin: string;
1142
+ }
1143
+ >
1144
+ ): void;
1145
+ addListener(
1146
+ event: "connect",
1147
+ listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1148
+ ): this;
1149
+ addListener(
1150
+ event: "stream",
1151
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1152
+ ): this;
1153
+ 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;
1156
+ emit(event: string | symbol, ...args: any[]): boolean;
1157
+ on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
1158
+ on(
1159
+ event: "stream",
1160
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1161
+ ): this;
1162
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1163
+ once(
1164
+ event: "connect",
1165
+ listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1166
+ ): this;
1167
+ once(
1168
+ event: "stream",
1169
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1170
+ ): this;
1171
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1172
+ prependListener(
1173
+ event: "connect",
1174
+ listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1175
+ ): this;
1176
+ prependListener(
1177
+ event: "stream",
1178
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1179
+ ): this;
1180
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1181
+ prependOnceListener(
1182
+ event: "connect",
1183
+ listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
1184
+ ): this;
1185
+ prependOnceListener(
1186
+ event: "stream",
1187
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1188
+ ): this;
1189
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1190
+ }
1191
+ // Http2Server
1192
+ export interface SessionOptions {
1193
+ maxDeflateDynamicTableSize?: number | undefined;
1194
+ maxSessionMemory?: number | undefined;
1195
+ maxHeaderListPairs?: number | undefined;
1196
+ maxOutstandingPings?: number | undefined;
1197
+ maxSendHeaderBlockLength?: number | undefined;
1198
+ paddingStrategy?: number | undefined;
1199
+ peerMaxConcurrentStreams?: number | undefined;
1200
+ settings?: Settings | undefined;
1201
+ /**
1202
+ * Specifies a timeout in milliseconds that
1203
+ * a server should wait when an [`'unknownProtocol'`][] is emitted. If the
1204
+ * socket has not been destroyed by that time the server will destroy it.
1205
+ * @default 100000
1206
+ */
1207
+ unknownProtocolTimeout?: number | undefined;
1208
+ selectPadding?(frameLen: number, maxFrameLen: number): number;
1209
+ }
1210
+ export interface ClientSessionOptions extends SessionOptions {
1211
+ maxReservedRemoteStreams?: number | undefined;
1212
+ createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1213
+ protocol?: "http:" | "https:" | undefined;
1214
+ }
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;
1220
+ }
1221
+ 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 {
1225
+ allowHTTP1?: boolean | undefined;
1226
+ origins?: string[] | undefined;
1227
+ }
1228
+ interface HTTP2ServerCommon {
1229
+ setTimeout(msec?: number, callback?: () => void): this;
1230
+ /**
1231
+ * Throws ERR_HTTP2_INVALID_SETTING_VALUE for invalid settings values.
1232
+ * Throws ERR_INVALID_ARG_TYPE for invalid settings argument.
1233
+ */
1234
+ updateSettings(settings: Settings): void;
1235
+ }
1236
+ export interface Http2Server extends net.Server, HTTP2ServerCommon {
1237
+ addListener(
1238
+ event: "checkContinue",
1239
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1240
+ ): this;
1241
+ addListener(
1242
+ event: "request",
1243
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1244
+ ): this;
1245
+ addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1246
+ addListener(event: "sessionError", listener: (err: Error) => void): this;
1247
+ addListener(
1248
+ event: "stream",
1249
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1250
+ ): this;
1251
+ addListener(event: "timeout", listener: () => void): this;
1252
+ 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;
1258
+ emit(event: "timeout"): boolean;
1259
+ emit(event: string | symbol, ...args: any[]): boolean;
1260
+ on(
1261
+ event: "checkContinue",
1262
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1263
+ ): 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
+ on(
1268
+ event: "stream",
1269
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1270
+ ): this;
1271
+ on(event: "timeout", listener: () => void): this;
1272
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1273
+ once(
1274
+ event: "checkContinue",
1275
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1276
+ ): 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
+ once(
1281
+ event: "stream",
1282
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1283
+ ): this;
1284
+ once(event: "timeout", listener: () => void): this;
1285
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1286
+ prependListener(
1287
+ event: "checkContinue",
1288
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1289
+ ): this;
1290
+ prependListener(
1291
+ event: "request",
1292
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1293
+ ): this;
1294
+ prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1295
+ prependListener(event: "sessionError", listener: (err: Error) => void): this;
1296
+ prependListener(
1297
+ event: "stream",
1298
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1299
+ ): this;
1300
+ prependListener(event: "timeout", listener: () => void): this;
1301
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1302
+ prependOnceListener(
1303
+ event: "checkContinue",
1304
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1305
+ ): this;
1306
+ prependOnceListener(
1307
+ event: "request",
1308
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1309
+ ): this;
1310
+ prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1311
+ prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1312
+ prependOnceListener(
1313
+ event: "stream",
1314
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1315
+ ): this;
1316
+ prependOnceListener(event: "timeout", listener: () => void): this;
1317
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1318
+ }
1319
+ export interface Http2SecureServer extends tls.Server, HTTP2ServerCommon {
1320
+ addListener(
1321
+ event: "checkContinue",
1322
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1323
+ ): this;
1324
+ addListener(
1325
+ event: "request",
1326
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1327
+ ): this;
1328
+ addListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1329
+ addListener(event: "sessionError", listener: (err: Error) => void): this;
1330
+ addListener(
1331
+ event: "stream",
1332
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1333
+ ): this;
1334
+ addListener(event: "timeout", listener: () => void): this;
1335
+ addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1336
+ 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;
1341
+ emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
1342
+ emit(event: "timeout"): boolean;
1343
+ emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean;
1344
+ emit(event: string | symbol, ...args: any[]): boolean;
1345
+ on(
1346
+ event: "checkContinue",
1347
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1348
+ ): 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
+ on(
1353
+ event: "stream",
1354
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1355
+ ): this;
1356
+ on(event: "timeout", listener: () => void): this;
1357
+ on(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1358
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1359
+ once(
1360
+ event: "checkContinue",
1361
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1362
+ ): 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
+ once(
1367
+ event: "stream",
1368
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1369
+ ): this;
1370
+ once(event: "timeout", listener: () => void): this;
1371
+ once(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1372
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1373
+ prependListener(
1374
+ event: "checkContinue",
1375
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1376
+ ): this;
1377
+ prependListener(
1378
+ event: "request",
1379
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1380
+ ): this;
1381
+ prependListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1382
+ prependListener(event: "sessionError", listener: (err: Error) => void): this;
1383
+ prependListener(
1384
+ event: "stream",
1385
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1386
+ ): this;
1387
+ prependListener(event: "timeout", listener: () => void): this;
1388
+ prependListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1389
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1390
+ prependOnceListener(
1391
+ event: "checkContinue",
1392
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1393
+ ): this;
1394
+ prependOnceListener(
1395
+ event: "request",
1396
+ listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
1397
+ ): this;
1398
+ prependOnceListener(event: "session", listener: (session: ServerHttp2Session) => void): this;
1399
+ prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
1400
+ prependOnceListener(
1401
+ event: "stream",
1402
+ listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,
1403
+ ): this;
1404
+ prependOnceListener(event: "timeout", listener: () => void): this;
1405
+ prependOnceListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
1406
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1407
+ }
1408
+ /**
1409
+ * A `Http2ServerRequest` object is created by {@link Server} or {@link SecureServer} and passed as the first argument to the `'request'` event. It may be used to access a request status,
1410
+ * headers, and
1411
+ * data.
1412
+ * @since v8.4.0
1413
+ */
1414
+ export class Http2ServerRequest extends stream.Readable {
1415
+ constructor(
1416
+ stream: ServerHttp2Stream,
1417
+ headers: IncomingHttpHeaders,
1418
+ options: stream.ReadableOptions,
1419
+ rawHeaders: readonly string[],
1420
+ );
1421
+ /**
1422
+ * The `request.aborted` property will be `true` if the request has
1423
+ * been aborted.
1424
+ * @since v10.1.0
1425
+ */
1426
+ readonly aborted: boolean;
1427
+ /**
1428
+ * 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']`.
1430
+ * @since v8.4.0
1431
+ */
1432
+ readonly authority: string;
1433
+ /**
1434
+ * See `request.socket`.
1435
+ * @since v8.4.0
1436
+ * @deprecated Since v13.0.0 - Use `socket`.
1437
+ */
1438
+ readonly connection: net.Socket | tls.TLSSocket;
1439
+ /**
1440
+ * The `request.complete` property will be `true` if the request has
1441
+ * been completed, aborted, or destroyed.
1442
+ * @since v12.10.0
1443
+ */
1444
+ readonly complete: boolean;
1445
+ /**
1446
+ * The request/response headers object.
1447
+ *
1448
+ * Key-value pairs of header names and values. Header names are lower-cased.
1449
+ *
1450
+ * ```js
1451
+ * // Prints something like:
1452
+ * //
1453
+ * // { 'user-agent': 'curl/7.22.0',
1454
+ * // host: '127.0.0.1:8000',
1455
+ * // accept: '*' }
1456
+ * console.log(request.headers);
1457
+ * ```
1458
+ *
1459
+ * See `HTTP/2 Headers Object`.
1460
+ *
1461
+ * In HTTP/2, the request path, host name, protocol, and method are represented as
1462
+ * special headers prefixed with the `:` character (e.g. `':path'`). These special
1463
+ * headers will be included in the `request.headers` object. Care must be taken not
1464
+ * to inadvertently modify these special headers or errors may occur. For instance,
1465
+ * removing all headers from the request will cause errors to occur:
1466
+ *
1467
+ * ```js
1468
+ * removeAllHeaders(request.headers);
1469
+ * assert(request.url); // Fails because the :path header has been removed
1470
+ * ```
1471
+ * @since v8.4.0
1472
+ */
1473
+ readonly headers: IncomingHttpHeaders;
1474
+ /**
1475
+ * 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'`.
1477
+ *
1478
+ * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1479
+ * @since v8.4.0
1480
+ */
1481
+ readonly httpVersion: string;
1482
+ readonly httpVersionMinor: number;
1483
+ readonly httpVersionMajor: number;
1484
+ /**
1485
+ * The request method as a string. Read-only. Examples: `'GET'`, `'DELETE'`.
1486
+ * @since v8.4.0
1487
+ */
1488
+ readonly method: string;
1489
+ /**
1490
+ * The raw request/response headers list exactly as they were received.
1491
+ *
1492
+ * The keys and values are in the same list. It is _not_ a
1493
+ * list of tuples. So, the even-numbered offsets are key values, and the
1494
+ * odd-numbered offsets are the associated values.
1495
+ *
1496
+ * Header names are not lowercased, and duplicates are not merged.
1497
+ *
1498
+ * ```js
1499
+ * // Prints something like:
1500
+ * //
1501
+ * // [ 'user-agent',
1502
+ * // 'this is invalid because there can be only one',
1503
+ * // 'User-Agent',
1504
+ * // 'curl/7.22.0',
1505
+ * // 'Host',
1506
+ * // '127.0.0.1:8000',
1507
+ * // 'ACCEPT',
1508
+ * // '*' ]
1509
+ * console.log(request.rawHeaders);
1510
+ * ```
1511
+ * @since v8.4.0
1512
+ */
1513
+ readonly rawHeaders: string[];
1514
+ /**
1515
+ * The raw request/response trailer keys and values exactly as they were
1516
+ * received. Only populated at the `'end'` event.
1517
+ * @since v8.4.0
1518
+ */
1519
+ readonly rawTrailers: string[];
1520
+ /**
1521
+ * The request scheme pseudo header field indicating the scheme
1522
+ * portion of the target URL.
1523
+ * @since v8.4.0
1524
+ */
1525
+ readonly scheme: string;
1526
+ /**
1527
+ * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1528
+ * applies getters, setters, and methods based on HTTP/2 logic.
1529
+ *
1530
+ * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1531
+ * set on `request.stream`.
1532
+ *
1533
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`request.stream`.
1534
+ *
1535
+ * `setTimeout` method will be called on `request.stream.session`.
1536
+ *
1537
+ * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1538
+ * more information.
1539
+ *
1540
+ * All other interactions will be routed directly to the socket. With TLS support,
1541
+ * use `request.socket.getPeerCertificate()` to obtain the client's
1542
+ * authentication details.
1543
+ * @since v8.4.0
1544
+ */
1545
+ readonly socket: net.Socket | tls.TLSSocket;
1546
+ /**
1547
+ * The `Http2Stream` object backing the request.
1548
+ * @since v8.4.0
1549
+ */
1550
+ readonly stream: ServerHttp2Stream;
1551
+ /**
1552
+ * The request/response trailers object. Only populated at the `'end'` event.
1553
+ * @since v8.4.0
1554
+ */
1555
+ readonly trailers: IncomingHttpHeaders;
1556
+ /**
1557
+ * Request URL string. This contains only the URL that is present in the actual
1558
+ * HTTP request. If the request is:
1559
+ *
1560
+ * ```http
1561
+ * GET /status?name=ryan HTTP/1.1
1562
+ * Accept: text/plain
1563
+ * ```
1564
+ *
1565
+ * Then `request.url` will be:
1566
+ *
1567
+ * ```js
1568
+ * '/status?name=ryan'
1569
+ * ```
1570
+ *
1571
+ * To parse the url into its parts, `new URL()` can be used:
1572
+ *
1573
+ * ```console
1574
+ * $ node
1575
+ * > new URL('/status?name=ryan', 'http://example.com')
1576
+ * URL {
1577
+ * href: 'http://example.com/status?name=ryan',
1578
+ * origin: 'http://example.com',
1579
+ * protocol: 'http:',
1580
+ * username: '',
1581
+ * password: '',
1582
+ * host: 'example.com',
1583
+ * hostname: 'example.com',
1584
+ * port: '',
1585
+ * pathname: '/status',
1586
+ * search: '?name=ryan',
1587
+ * searchParams: URLSearchParams { 'name' => 'ryan' },
1588
+ * hash: ''
1589
+ * }
1590
+ * ```
1591
+ * @since v8.4.0
1592
+ */
1593
+ url: string;
1594
+ /**
1595
+ * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is
1596
+ * provided, then it is added as a listener on the `'timeout'` event on
1597
+ * the response object.
1598
+ *
1599
+ * 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
1601
+ * handler is assigned to the request, the response, or the server's `'timeout'`events, timed out sockets must be handled explicitly.
1602
+ * @since v8.4.0
1603
+ */
1604
+ setTimeout(msecs: number, callback?: () => void): void;
1605
+ read(size?: number): Buffer | string | null;
1606
+ addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1607
+ addListener(event: "close", listener: () => void): this;
1608
+ addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
1609
+ addListener(event: "end", listener: () => void): this;
1610
+ addListener(event: "readable", listener: () => void): this;
1611
+ addListener(event: "error", listener: (err: Error) => void): this;
1612
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1613
+ emit(event: "aborted", hadError: boolean, code: number): boolean;
1614
+ emit(event: "close"): boolean;
1615
+ emit(event: "data", chunk: Buffer | string): boolean;
1616
+ emit(event: "end"): boolean;
1617
+ emit(event: "readable"): boolean;
1618
+ emit(event: "error", err: Error): boolean;
1619
+ emit(event: string | symbol, ...args: any[]): boolean;
1620
+ on(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1621
+ on(event: "close", listener: () => void): this;
1622
+ on(event: "data", listener: (chunk: Buffer | string) => void): this;
1623
+ on(event: "end", listener: () => void): this;
1624
+ on(event: "readable", listener: () => void): this;
1625
+ on(event: "error", listener: (err: Error) => void): this;
1626
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1627
+ once(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1628
+ once(event: "close", listener: () => void): this;
1629
+ once(event: "data", listener: (chunk: Buffer | string) => void): this;
1630
+ once(event: "end", listener: () => void): this;
1631
+ once(event: "readable", listener: () => void): this;
1632
+ once(event: "error", listener: (err: Error) => void): this;
1633
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1634
+ prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1635
+ prependListener(event: "close", listener: () => void): this;
1636
+ prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
1637
+ prependListener(event: "end", listener: () => void): this;
1638
+ prependListener(event: "readable", listener: () => void): this;
1639
+ prependListener(event: "error", listener: (err: Error) => void): this;
1640
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1641
+ prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
1642
+ prependOnceListener(event: "close", listener: () => void): this;
1643
+ prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
1644
+ prependOnceListener(event: "end", listener: () => void): this;
1645
+ prependOnceListener(event: "readable", listener: () => void): this;
1646
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
1647
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1648
+ }
1649
+ /**
1650
+ * This object is created internally by an HTTP server, not by the user. It is
1651
+ * passed as the second parameter to the `'request'` event.
1652
+ * @since v8.4.0
1653
+ */
1654
+ export class Http2ServerResponse extends stream.Writable {
1655
+ constructor(stream: ServerHttp2Stream);
1656
+ /**
1657
+ * See `response.socket`.
1658
+ * @since v8.4.0
1659
+ * @deprecated Since v13.0.0 - Use `socket`.
1660
+ */
1661
+ readonly connection: net.Socket | tls.TLSSocket;
1662
+ /**
1663
+ * Boolean value that indicates whether the response has completed. Starts
1664
+ * as `false`. After `response.end()` executes, the value will be `true`.
1665
+ * @since v8.4.0
1666
+ * @deprecated Since v13.4.0,v12.16.0 - Use `writableEnded`.
1667
+ */
1668
+ readonly finished: boolean;
1669
+ /**
1670
+ * True if headers were sent, false otherwise (read-only).
1671
+ * @since v8.4.0
1672
+ */
1673
+ readonly headersSent: boolean;
1674
+ /**
1675
+ * A reference to the original HTTP2 `request` object.
1676
+ * @since v15.7.0
1677
+ */
1678
+ readonly req: Http2ServerRequest;
1679
+ /**
1680
+ * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but
1681
+ * applies getters, setters, and methods based on HTTP/2 logic.
1682
+ *
1683
+ * `destroyed`, `readable`, and `writable` properties will be retrieved from and
1684
+ * set on `response.stream`.
1685
+ *
1686
+ * `destroy`, `emit`, `end`, `on` and `once` methods will be called on`response.stream`.
1687
+ *
1688
+ * `setTimeout` method will be called on `response.stream.session`.
1689
+ *
1690
+ * `pause`, `read`, `resume`, and `write` will throw an error with code`ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for
1691
+ * more information.
1692
+ *
1693
+ * All other interactions will be routed directly to the socket.
1694
+ *
1695
+ * ```js
1696
+ * const http2 = require('node:http2');
1697
+ * const server = http2.createServer((req, res) => {
1698
+ * const ip = req.socket.remoteAddress;
1699
+ * const port = req.socket.remotePort;
1700
+ * res.end(`Your IP address is ${ip} and your source port is ${port}.`);
1701
+ * }).listen(3000);
1702
+ * ```
1703
+ * @since v8.4.0
1704
+ */
1705
+ readonly socket: net.Socket | tls.TLSSocket;
1706
+ /**
1707
+ * The `Http2Stream` object backing the response.
1708
+ * @since v8.4.0
1709
+ */
1710
+ readonly stream: ServerHttp2Stream;
1711
+ /**
1712
+ * When true, the Date header will be automatically generated and sent in
1713
+ * the response if it is not already present in the headers. Defaults to true.
1714
+ *
1715
+ * This should only be disabled for testing; HTTP requires the Date header
1716
+ * in responses.
1717
+ * @since v8.4.0
1718
+ */
1719
+ sendDate: boolean;
1720
+ /**
1721
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
1722
+ * this property controls the status code that will be sent to the client when
1723
+ * the headers get flushed.
1724
+ *
1725
+ * ```js
1726
+ * response.statusCode = 404;
1727
+ * ```
1728
+ *
1729
+ * After response header was sent to the client, this property indicates the
1730
+ * status code which was sent out.
1731
+ * @since v8.4.0
1732
+ */
1733
+ statusCode: number;
1734
+ /**
1735
+ * Status message is not supported by HTTP/2 (RFC 7540 8.1.2.4). It returns
1736
+ * an empty string.
1737
+ * @since v8.4.0
1738
+ */
1739
+ statusMessage: "";
1740
+ /**
1741
+ * This method adds HTTP trailing headers (a header but at the end of the
1742
+ * message) to the response.
1743
+ *
1744
+ * Attempting to set a header field name or value that contains invalid characters
1745
+ * will result in a `TypeError` being thrown.
1746
+ * @since v8.4.0
1747
+ */
1748
+ addTrailers(trailers: OutgoingHttpHeaders): void;
1749
+ /**
1750
+ * This method signals to the server that all of the response headers and body
1751
+ * have been sent; that server should consider this message complete.
1752
+ * The method, `response.end()`, MUST be called on each response.
1753
+ *
1754
+ * If `data` is specified, it is equivalent to calling `response.write(data, encoding)` followed by `response.end(callback)`.
1755
+ *
1756
+ * If `callback` is specified, it will be called when the response stream
1757
+ * is finished.
1758
+ * @since v8.4.0
1759
+ */
1760
+ end(callback?: () => void): this;
1761
+ end(data: string | Uint8Array, callback?: () => void): this;
1762
+ end(data: string | Uint8Array, encoding: BufferEncoding, callback?: () => void): this;
1763
+ /**
1764
+ * Reads out a header that has already been queued but not sent to the client.
1765
+ * The name is case-insensitive.
1766
+ *
1767
+ * ```js
1768
+ * const contentType = response.getHeader('content-type');
1769
+ * ```
1770
+ * @since v8.4.0
1771
+ */
1772
+ getHeader(name: string): string;
1773
+ /**
1774
+ * Returns an array containing the unique names of the current outgoing headers.
1775
+ * All header names are lowercase.
1776
+ *
1777
+ * ```js
1778
+ * response.setHeader('Foo', 'bar');
1779
+ * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
1780
+ *
1781
+ * const headerNames = response.getHeaderNames();
1782
+ * // headerNames === ['foo', 'set-cookie']
1783
+ * ```
1784
+ * @since v8.4.0
1785
+ */
1786
+ getHeaderNames(): string[];
1787
+ /**
1788
+ * Returns a shallow copy of the current outgoing headers. Since a shallow copy
1789
+ * is used, array values may be mutated without additional calls to various
1790
+ * header-related http module methods. The keys of the returned object are the
1791
+ * header names and the values are the respective header values. All header names
1792
+ * are lowercase.
1793
+ *
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()`,
1795
+ * `obj.hasOwnProperty()`, and others
1796
+ * are not defined and _will not work_.
1797
+ *
1798
+ * ```js
1799
+ * response.setHeader('Foo', 'bar');
1800
+ * response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
1801
+ *
1802
+ * const headers = response.getHeaders();
1803
+ * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
1804
+ * ```
1805
+ * @since v8.4.0
1806
+ */
1807
+ getHeaders(): OutgoingHttpHeaders;
1808
+ /**
1809
+ * Returns `true` if the header identified by `name` is currently set in the
1810
+ * outgoing headers. The header name matching is case-insensitive.
1811
+ *
1812
+ * ```js
1813
+ * const hasContentType = response.hasHeader('content-type');
1814
+ * ```
1815
+ * @since v8.4.0
1816
+ */
1817
+ hasHeader(name: string): boolean;
1818
+ /**
1819
+ * Removes a header that has been queued for implicit sending.
1820
+ *
1821
+ * ```js
1822
+ * response.removeHeader('Content-Encoding');
1823
+ * ```
1824
+ * @since v8.4.0
1825
+ */
1826
+ removeHeader(name: string): void;
1827
+ /**
1828
+ * Sets a single header value for implicit headers. If this header already exists
1829
+ * in the to-be-sent headers, its value will be replaced. Use an array of strings
1830
+ * here to send multiple headers with the same name.
1831
+ *
1832
+ * ```js
1833
+ * response.setHeader('Content-Type', 'text/html; charset=utf-8');
1834
+ * ```
1835
+ *
1836
+ * or
1837
+ *
1838
+ * ```js
1839
+ * response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
1840
+ * ```
1841
+ *
1842
+ * Attempting to set a header field name or value that contains invalid characters
1843
+ * will result in a `TypeError` being thrown.
1844
+ *
1845
+ * When headers have been set with `response.setHeader()`, they will be merged
1846
+ * with any headers passed to `response.writeHead()`, with the headers passed
1847
+ * to `response.writeHead()` given precedence.
1848
+ *
1849
+ * ```js
1850
+ * // Returns content-type = text/plain
1851
+ * const server = http2.createServer((req, res) => {
1852
+ * res.setHeader('Content-Type', 'text/html; charset=utf-8');
1853
+ * res.setHeader('X-Foo', 'bar');
1854
+ * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
1855
+ * res.end('ok');
1856
+ * });
1857
+ * ```
1858
+ * @since v8.4.0
1859
+ */
1860
+ setHeader(name: string, value: number | string | readonly string[]): void;
1861
+ /**
1862
+ * Sets the `Http2Stream`'s timeout value to `msecs`. If a callback is
1863
+ * provided, then it is added as a listener on the `'timeout'` event on
1864
+ * the response object.
1865
+ *
1866
+ * If no `'timeout'` listener is added to the request, the response, or
1867
+ * 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.
1869
+ * @since v8.4.0
1870
+ */
1871
+ setTimeout(msecs: number, callback?: () => void): void;
1872
+ /**
1873
+ * If this method is called and `response.writeHead()` has not been called,
1874
+ * it will switch to implicit header mode and flush the implicit headers.
1875
+ *
1876
+ * This sends a chunk of the response body. This method may
1877
+ * be called multiple times to provide successive parts of the body.
1878
+ *
1879
+ * In the `node:http` module, the response body is omitted when the
1880
+ * request is a HEAD request. Similarly, the `204` and `304` responses _must not_ include a message body.
1881
+ *
1882
+ * `chunk` can be a string or a buffer. If `chunk` is a string,
1883
+ * the second parameter specifies how to encode it into a byte stream.
1884
+ * By default the `encoding` is `'utf8'`. `callback` will be called when this chunk
1885
+ * of data is flushed.
1886
+ *
1887
+ * This is the raw HTTP body and has nothing to do with higher-level multi-part
1888
+ * body encodings that may be used.
1889
+ *
1890
+ * The first time `response.write()` is called, it will send the buffered
1891
+ * header information and the first chunk of the body to the client. The second
1892
+ * time `response.write()` is called, Node.js assumes data will be streamed,
1893
+ * and sends the new data separately. That is, the response is buffered up to the
1894
+ * first chunk of the body.
1895
+ *
1896
+ * Returns `true` if the entire data was flushed successfully to the kernel
1897
+ * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is free again.
1898
+ * @since v8.4.0
1899
+ */
1900
+ write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean;
1901
+ write(chunk: string | Uint8Array, encoding: BufferEncoding, callback?: (err: Error) => void): boolean;
1902
+ /**
1903
+ * 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`.
1905
+ * @since v8.4.0
1906
+ */
1907
+ writeContinue(): void;
1908
+ /**
1909
+ * Sends a status `103 Early Hints` to the client with a Link header,
1910
+ * indicating that the user agent can preload/preconnect the linked resources.
1911
+ * The `hints` is an object containing the values of headers to be sent with
1912
+ * early hints message.
1913
+ *
1914
+ * **Example**
1915
+ *
1916
+ * ```js
1917
+ * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
1918
+ * response.writeEarlyHints({
1919
+ * 'link': earlyHintsLink,
1920
+ * });
1921
+ *
1922
+ * const earlyHintsLinks = [
1923
+ * '</styles.css>; rel=preload; as=style',
1924
+ * '</scripts.js>; rel=preload; as=script',
1925
+ * ];
1926
+ * response.writeEarlyHints({
1927
+ * 'link': earlyHintsLinks,
1928
+ * });
1929
+ * ```
1930
+ * @since v18.11.0
1931
+ */
1932
+ writeEarlyHints(hints: Record<string, string | string[]>): void;
1933
+ /**
1934
+ * Sends a response header to the request. The status code is a 3-digit HTTP
1935
+ * status code, like `404`. The last argument, `headers`, are the response headers.
1936
+ *
1937
+ * Returns a reference to the `Http2ServerResponse`, so that calls can be chained.
1938
+ *
1939
+ * For compatibility with `HTTP/1`, a human-readable `statusMessage` may be
1940
+ * passed as the second argument. However, because the `statusMessage` has no
1941
+ * meaning within HTTP/2, the argument will have no effect and a process warning
1942
+ * will be emitted.
1943
+ *
1944
+ * ```js
1945
+ * const body = 'hello world';
1946
+ * response.writeHead(200, {
1947
+ * 'Content-Length': Buffer.byteLength(body),
1948
+ * 'Content-Type': 'text/plain; charset=utf-8',
1949
+ * });
1950
+ * ```
1951
+ *
1952
+ * `Content-Length` is given in bytes not characters. The`Buffer.byteLength()` API may be used to determine the number of bytes in a
1953
+ * given encoding. On outbound messages, Node.js does not check if Content-Length
1954
+ * 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.
1956
+ *
1957
+ * This method may be called at most one time on a message before `response.end()` is called.
1958
+ *
1959
+ * If `response.write()` or `response.end()` are called before calling
1960
+ * this, the implicit/mutable headers will be calculated and call this function.
1961
+ *
1962
+ * When headers have been set with `response.setHeader()`, they will be merged
1963
+ * with any headers passed to `response.writeHead()`, with the headers passed
1964
+ * to `response.writeHead()` given precedence.
1965
+ *
1966
+ * ```js
1967
+ * // Returns content-type = text/plain
1968
+ * const server = http2.createServer((req, res) => {
1969
+ * res.setHeader('Content-Type', 'text/html; charset=utf-8');
1970
+ * res.setHeader('X-Foo', 'bar');
1971
+ * res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
1972
+ * res.end('ok');
1973
+ * });
1974
+ * ```
1975
+ *
1976
+ * Attempting to set a header field name or value that contains invalid characters
1977
+ * will result in a `TypeError` being thrown.
1978
+ * @since v8.4.0
1979
+ */
1980
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this;
1981
+ writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this;
1982
+ /**
1983
+ * Call `http2stream.pushStream()` with the given headers, and wrap the
1984
+ * given `Http2Stream` on a newly created `Http2ServerResponse` as the callback
1985
+ * parameter if successful. When `Http2ServerRequest` is closed, the callback is
1986
+ * called with an error `ERR_HTTP2_INVALID_STREAM`.
1987
+ * @since v8.4.0
1988
+ * @param headers An object describing the headers
1989
+ * @param callback Called once `http2stream.pushStream()` is finished, or either when the attempt to create the pushed `Http2Stream` has failed or has been rejected, or the state of
1990
+ * `Http2ServerRequest` is closed prior to calling the `http2stream.pushStream()` method
1991
+ */
1992
+ createPushResponse(
1993
+ headers: OutgoingHttpHeaders,
1994
+ callback: (err: Error | null, res: Http2ServerResponse) => void,
1995
+ ): void;
1996
+ addListener(event: "close", listener: () => void): this;
1997
+ addListener(event: "drain", listener: () => void): this;
1998
+ addListener(event: "error", listener: (error: Error) => void): this;
1999
+ addListener(event: "finish", listener: () => void): this;
2000
+ addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
2001
+ addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
2002
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
2003
+ emit(event: "close"): boolean;
2004
+ emit(event: "drain"): boolean;
2005
+ emit(event: "error", error: Error): boolean;
2006
+ emit(event: "finish"): boolean;
2007
+ emit(event: "pipe", src: stream.Readable): boolean;
2008
+ emit(event: "unpipe", src: stream.Readable): boolean;
2009
+ emit(event: string | symbol, ...args: any[]): boolean;
2010
+ on(event: "close", listener: () => void): this;
2011
+ on(event: "drain", listener: () => void): this;
2012
+ on(event: "error", listener: (error: Error) => void): this;
2013
+ on(event: "finish", listener: () => void): this;
2014
+ on(event: "pipe", listener: (src: stream.Readable) => void): this;
2015
+ on(event: "unpipe", listener: (src: stream.Readable) => void): this;
2016
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
2017
+ once(event: "close", listener: () => void): this;
2018
+ once(event: "drain", listener: () => void): this;
2019
+ once(event: "error", listener: (error: Error) => void): this;
2020
+ once(event: "finish", listener: () => void): this;
2021
+ once(event: "pipe", listener: (src: stream.Readable) => void): this;
2022
+ once(event: "unpipe", listener: (src: stream.Readable) => void): this;
2023
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
2024
+ prependListener(event: "close", listener: () => void): this;
2025
+ prependListener(event: "drain", listener: () => void): this;
2026
+ prependListener(event: "error", listener: (error: Error) => void): this;
2027
+ prependListener(event: "finish", listener: () => void): this;
2028
+ prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
2029
+ prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
2030
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
2031
+ prependOnceListener(event: "close", listener: () => void): this;
2032
+ prependOnceListener(event: "drain", listener: () => void): this;
2033
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
2034
+ prependOnceListener(event: "finish", listener: () => void): this;
2035
+ prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
2036
+ prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
2037
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
2038
+ }
2039
+ export namespace constants {
2040
+ const NGHTTP2_SESSION_SERVER: number;
2041
+ const NGHTTP2_SESSION_CLIENT: number;
2042
+ const NGHTTP2_STREAM_STATE_IDLE: number;
2043
+ const NGHTTP2_STREAM_STATE_OPEN: number;
2044
+ const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number;
2045
+ const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number;
2046
+ const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number;
2047
+ const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number;
2048
+ const NGHTTP2_STREAM_STATE_CLOSED: number;
2049
+ const NGHTTP2_NO_ERROR: number;
2050
+ const NGHTTP2_PROTOCOL_ERROR: number;
2051
+ const NGHTTP2_INTERNAL_ERROR: number;
2052
+ const NGHTTP2_FLOW_CONTROL_ERROR: number;
2053
+ const NGHTTP2_SETTINGS_TIMEOUT: number;
2054
+ const NGHTTP2_STREAM_CLOSED: number;
2055
+ const NGHTTP2_FRAME_SIZE_ERROR: number;
2056
+ const NGHTTP2_REFUSED_STREAM: number;
2057
+ const NGHTTP2_CANCEL: number;
2058
+ const NGHTTP2_COMPRESSION_ERROR: number;
2059
+ const NGHTTP2_CONNECT_ERROR: number;
2060
+ const NGHTTP2_ENHANCE_YOUR_CALM: number;
2061
+ const NGHTTP2_INADEQUATE_SECURITY: number;
2062
+ const NGHTTP2_HTTP_1_1_REQUIRED: number;
2063
+ const NGHTTP2_ERR_FRAME_SIZE_ERROR: number;
2064
+ const NGHTTP2_FLAG_NONE: number;
2065
+ const NGHTTP2_FLAG_END_STREAM: number;
2066
+ const NGHTTP2_FLAG_END_HEADERS: number;
2067
+ const NGHTTP2_FLAG_ACK: number;
2068
+ const NGHTTP2_FLAG_PADDED: number;
2069
+ const NGHTTP2_FLAG_PRIORITY: number;
2070
+ const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number;
2071
+ const DEFAULT_SETTINGS_ENABLE_PUSH: number;
2072
+ const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number;
2073
+ const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number;
2074
+ const MAX_MAX_FRAME_SIZE: number;
2075
+ const MIN_MAX_FRAME_SIZE: number;
2076
+ const MAX_INITIAL_WINDOW_SIZE: number;
2077
+ const NGHTTP2_DEFAULT_WEIGHT: number;
2078
+ const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number;
2079
+ const NGHTTP2_SETTINGS_ENABLE_PUSH: number;
2080
+ const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number;
2081
+ const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number;
2082
+ const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number;
2083
+ const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number;
2084
+ const PADDING_STRATEGY_NONE: number;
2085
+ const PADDING_STRATEGY_MAX: number;
2086
+ const PADDING_STRATEGY_CALLBACK: number;
2087
+ const HTTP2_HEADER_STATUS: string;
2088
+ const HTTP2_HEADER_METHOD: string;
2089
+ const HTTP2_HEADER_AUTHORITY: string;
2090
+ const HTTP2_HEADER_SCHEME: string;
2091
+ const HTTP2_HEADER_PATH: string;
2092
+ const HTTP2_HEADER_ACCEPT_CHARSET: string;
2093
+ const HTTP2_HEADER_ACCEPT_ENCODING: string;
2094
+ const HTTP2_HEADER_ACCEPT_LANGUAGE: string;
2095
+ const HTTP2_HEADER_ACCEPT_RANGES: string;
2096
+ const HTTP2_HEADER_ACCEPT: string;
2097
+ const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string;
2098
+ const HTTP2_HEADER_AGE: string;
2099
+ const HTTP2_HEADER_ALLOW: string;
2100
+ const HTTP2_HEADER_AUTHORIZATION: string;
2101
+ const HTTP2_HEADER_CACHE_CONTROL: string;
2102
+ const HTTP2_HEADER_CONNECTION: string;
2103
+ const HTTP2_HEADER_CONTENT_DISPOSITION: string;
2104
+ const HTTP2_HEADER_CONTENT_ENCODING: string;
2105
+ const HTTP2_HEADER_CONTENT_LANGUAGE: string;
2106
+ const HTTP2_HEADER_CONTENT_LENGTH: string;
2107
+ const HTTP2_HEADER_CONTENT_LOCATION: string;
2108
+ const HTTP2_HEADER_CONTENT_MD5: string;
2109
+ const HTTP2_HEADER_CONTENT_RANGE: string;
2110
+ const HTTP2_HEADER_CONTENT_TYPE: string;
2111
+ const HTTP2_HEADER_COOKIE: string;
2112
+ const HTTP2_HEADER_DATE: string;
2113
+ const HTTP2_HEADER_ETAG: string;
2114
+ const HTTP2_HEADER_EXPECT: string;
2115
+ const HTTP2_HEADER_EXPIRES: string;
2116
+ const HTTP2_HEADER_FROM: string;
2117
+ const HTTP2_HEADER_HOST: string;
2118
+ const HTTP2_HEADER_IF_MATCH: string;
2119
+ const HTTP2_HEADER_IF_MODIFIED_SINCE: string;
2120
+ const HTTP2_HEADER_IF_NONE_MATCH: string;
2121
+ const HTTP2_HEADER_IF_RANGE: string;
2122
+ const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string;
2123
+ const HTTP2_HEADER_LAST_MODIFIED: string;
2124
+ const HTTP2_HEADER_LINK: string;
2125
+ const HTTP2_HEADER_LOCATION: string;
2126
+ const HTTP2_HEADER_MAX_FORWARDS: string;
2127
+ const HTTP2_HEADER_PREFER: string;
2128
+ const HTTP2_HEADER_PROXY_AUTHENTICATE: string;
2129
+ const HTTP2_HEADER_PROXY_AUTHORIZATION: string;
2130
+ const HTTP2_HEADER_RANGE: string;
2131
+ const HTTP2_HEADER_REFERER: string;
2132
+ const HTTP2_HEADER_REFRESH: string;
2133
+ const HTTP2_HEADER_RETRY_AFTER: string;
2134
+ const HTTP2_HEADER_SERVER: string;
2135
+ const HTTP2_HEADER_SET_COOKIE: string;
2136
+ const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string;
2137
+ const HTTP2_HEADER_TRANSFER_ENCODING: string;
2138
+ const HTTP2_HEADER_TE: string;
2139
+ const HTTP2_HEADER_UPGRADE: string;
2140
+ const HTTP2_HEADER_USER_AGENT: string;
2141
+ const HTTP2_HEADER_VARY: string;
2142
+ const HTTP2_HEADER_VIA: string;
2143
+ const HTTP2_HEADER_WWW_AUTHENTICATE: string;
2144
+ const HTTP2_HEADER_HTTP2_SETTINGS: string;
2145
+ const HTTP2_HEADER_KEEP_ALIVE: string;
2146
+ const HTTP2_HEADER_PROXY_CONNECTION: string;
2147
+ const HTTP2_METHOD_ACL: string;
2148
+ const HTTP2_METHOD_BASELINE_CONTROL: string;
2149
+ const HTTP2_METHOD_BIND: string;
2150
+ const HTTP2_METHOD_CHECKIN: string;
2151
+ const HTTP2_METHOD_CHECKOUT: string;
2152
+ const HTTP2_METHOD_CONNECT: string;
2153
+ const HTTP2_METHOD_COPY: string;
2154
+ const HTTP2_METHOD_DELETE: string;
2155
+ const HTTP2_METHOD_GET: string;
2156
+ const HTTP2_METHOD_HEAD: string;
2157
+ const HTTP2_METHOD_LABEL: string;
2158
+ const HTTP2_METHOD_LINK: string;
2159
+ const HTTP2_METHOD_LOCK: string;
2160
+ const HTTP2_METHOD_MERGE: string;
2161
+ const HTTP2_METHOD_MKACTIVITY: string;
2162
+ const HTTP2_METHOD_MKCALENDAR: string;
2163
+ const HTTP2_METHOD_MKCOL: string;
2164
+ const HTTP2_METHOD_MKREDIRECTREF: string;
2165
+ const HTTP2_METHOD_MKWORKSPACE: string;
2166
+ const HTTP2_METHOD_MOVE: string;
2167
+ const HTTP2_METHOD_OPTIONS: string;
2168
+ const HTTP2_METHOD_ORDERPATCH: string;
2169
+ const HTTP2_METHOD_PATCH: string;
2170
+ const HTTP2_METHOD_POST: string;
2171
+ const HTTP2_METHOD_PRI: string;
2172
+ const HTTP2_METHOD_PROPFIND: string;
2173
+ const HTTP2_METHOD_PROPPATCH: string;
2174
+ const HTTP2_METHOD_PUT: string;
2175
+ const HTTP2_METHOD_REBIND: string;
2176
+ const HTTP2_METHOD_REPORT: string;
2177
+ const HTTP2_METHOD_SEARCH: string;
2178
+ const HTTP2_METHOD_TRACE: string;
2179
+ const HTTP2_METHOD_UNBIND: string;
2180
+ const HTTP2_METHOD_UNCHECKOUT: string;
2181
+ const HTTP2_METHOD_UNLINK: string;
2182
+ const HTTP2_METHOD_UNLOCK: string;
2183
+ const HTTP2_METHOD_UPDATE: string;
2184
+ const HTTP2_METHOD_UPDATEREDIRECTREF: string;
2185
+ const HTTP2_METHOD_VERSION_CONTROL: string;
2186
+ const HTTP_STATUS_CONTINUE: number;
2187
+ const HTTP_STATUS_SWITCHING_PROTOCOLS: number;
2188
+ const HTTP_STATUS_PROCESSING: number;
2189
+ const HTTP_STATUS_OK: number;
2190
+ const HTTP_STATUS_CREATED: number;
2191
+ const HTTP_STATUS_ACCEPTED: number;
2192
+ const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number;
2193
+ const HTTP_STATUS_NO_CONTENT: number;
2194
+ const HTTP_STATUS_RESET_CONTENT: number;
2195
+ const HTTP_STATUS_PARTIAL_CONTENT: number;
2196
+ const HTTP_STATUS_MULTI_STATUS: number;
2197
+ const HTTP_STATUS_ALREADY_REPORTED: number;
2198
+ const HTTP_STATUS_IM_USED: number;
2199
+ const HTTP_STATUS_MULTIPLE_CHOICES: number;
2200
+ const HTTP_STATUS_MOVED_PERMANENTLY: number;
2201
+ const HTTP_STATUS_FOUND: number;
2202
+ const HTTP_STATUS_SEE_OTHER: number;
2203
+ const HTTP_STATUS_NOT_MODIFIED: number;
2204
+ const HTTP_STATUS_USE_PROXY: number;
2205
+ const HTTP_STATUS_TEMPORARY_REDIRECT: number;
2206
+ const HTTP_STATUS_PERMANENT_REDIRECT: number;
2207
+ const HTTP_STATUS_BAD_REQUEST: number;
2208
+ const HTTP_STATUS_UNAUTHORIZED: number;
2209
+ const HTTP_STATUS_PAYMENT_REQUIRED: number;
2210
+ const HTTP_STATUS_FORBIDDEN: number;
2211
+ const HTTP_STATUS_NOT_FOUND: number;
2212
+ const HTTP_STATUS_METHOD_NOT_ALLOWED: number;
2213
+ const HTTP_STATUS_NOT_ACCEPTABLE: number;
2214
+ const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number;
2215
+ const HTTP_STATUS_REQUEST_TIMEOUT: number;
2216
+ const HTTP_STATUS_CONFLICT: number;
2217
+ const HTTP_STATUS_GONE: number;
2218
+ const HTTP_STATUS_LENGTH_REQUIRED: number;
2219
+ const HTTP_STATUS_PRECONDITION_FAILED: number;
2220
+ const HTTP_STATUS_PAYLOAD_TOO_LARGE: number;
2221
+ const HTTP_STATUS_URI_TOO_LONG: number;
2222
+ const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number;
2223
+ const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number;
2224
+ const HTTP_STATUS_EXPECTATION_FAILED: number;
2225
+ const HTTP_STATUS_TEAPOT: number;
2226
+ const HTTP_STATUS_MISDIRECTED_REQUEST: number;
2227
+ const HTTP_STATUS_UNPROCESSABLE_ENTITY: number;
2228
+ const HTTP_STATUS_LOCKED: number;
2229
+ const HTTP_STATUS_FAILED_DEPENDENCY: number;
2230
+ const HTTP_STATUS_UNORDERED_COLLECTION: number;
2231
+ const HTTP_STATUS_UPGRADE_REQUIRED: number;
2232
+ const HTTP_STATUS_PRECONDITION_REQUIRED: number;
2233
+ const HTTP_STATUS_TOO_MANY_REQUESTS: number;
2234
+ const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number;
2235
+ const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number;
2236
+ const HTTP_STATUS_INTERNAL_SERVER_ERROR: number;
2237
+ const HTTP_STATUS_NOT_IMPLEMENTED: number;
2238
+ const HTTP_STATUS_BAD_GATEWAY: number;
2239
+ const HTTP_STATUS_SERVICE_UNAVAILABLE: number;
2240
+ const HTTP_STATUS_GATEWAY_TIMEOUT: number;
2241
+ const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number;
2242
+ const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number;
2243
+ const HTTP_STATUS_INSUFFICIENT_STORAGE: number;
2244
+ const HTTP_STATUS_LOOP_DETECTED: number;
2245
+ const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number;
2246
+ const HTTP_STATUS_NOT_EXTENDED: number;
2247
+ const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number;
2248
+ }
2249
+ /**
2250
+ * This symbol can be set as a property on the HTTP/2 headers object with
2251
+ * an array value in order to provide a list of headers considered sensitive.
2252
+ */
2253
+ export const sensitiveHeaders: symbol;
2254
+ /**
2255
+ * Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called
2256
+ * so instances returned may be safely modified for use.
2257
+ * @since v8.4.0
2258
+ */
2259
+ export function getDefaultSettings(): Settings;
2260
+ /**
2261
+ * Returns a `Buffer` instance containing serialized representation of the given
2262
+ * HTTP/2 settings as specified in the [HTTP/2](https://tools.ietf.org/html/rfc7540) specification. This is intended
2263
+ * for use with the `HTTP2-Settings` header field.
2264
+ *
2265
+ * ```js
2266
+ * const http2 = require('node:http2');
2267
+ *
2268
+ * const packed = http2.getPackedSettings({ enablePush: false });
2269
+ *
2270
+ * console.log(packed.toString('base64'));
2271
+ * // Prints: AAIAAAAA
2272
+ * ```
2273
+ * @since v8.4.0
2274
+ */
2275
+ export function getPackedSettings(settings: Settings): Buffer;
2276
+ /**
2277
+ * Returns a `HTTP/2 Settings Object` containing the deserialized settings from
2278
+ * the given `Buffer` as generated by `http2.getPackedSettings()`.
2279
+ * @since v8.4.0
2280
+ * @param buf The packed settings.
2281
+ */
2282
+ export function getUnpackedSettings(buf: Uint8Array): Settings;
2283
+ /**
2284
+ * Returns a `net.Server` instance that creates and manages `Http2Session`instances.
2285
+ *
2286
+ * 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
+ * communicating
2288
+ * with browser clients.
2289
+ *
2290
+ * ```js
2291
+ * const http2 = require('node:http2');
2292
+ *
2293
+ * // Create an unencrypted HTTP/2 server.
2294
+ * // Since there are no browsers known that support
2295
+ * // unencrypted HTTP/2, the use of `http2.createSecureServer()`
2296
+ * // is necessary when communicating with browser clients.
2297
+ * const server = http2.createServer();
2298
+ *
2299
+ * server.on('stream', (stream, headers) => {
2300
+ * stream.respond({
2301
+ * 'content-type': 'text/html; charset=utf-8',
2302
+ * ':status': 200,
2303
+ * });
2304
+ * stream.end('<h1>Hello World</h1>');
2305
+ * });
2306
+ *
2307
+ * server.listen(8000);
2308
+ * ```
2309
+ * @since v8.4.0
2310
+ * @param onRequestHandler See `Compatibility API`
2311
+ */
2312
+ export function createServer(
2313
+ onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2314
+ ): Http2Server;
2315
+ export function createServer(
2316
+ options: ServerOptions,
2317
+ onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2318
+ ): Http2Server;
2319
+ /**
2320
+ * Returns a `tls.Server` instance that creates and manages `Http2Session`instances.
2321
+ *
2322
+ * ```js
2323
+ * const http2 = require('node:http2');
2324
+ * const fs = require('node:fs');
2325
+ *
2326
+ * const options = {
2327
+ * key: fs.readFileSync('server-key.pem'),
2328
+ * cert: fs.readFileSync('server-cert.pem'),
2329
+ * };
2330
+ *
2331
+ * // Create a secure HTTP/2 server
2332
+ * const server = http2.createSecureServer(options);
2333
+ *
2334
+ * server.on('stream', (stream, headers) => {
2335
+ * stream.respond({
2336
+ * 'content-type': 'text/html; charset=utf-8',
2337
+ * ':status': 200,
2338
+ * });
2339
+ * stream.end('<h1>Hello World</h1>');
2340
+ * });
2341
+ *
2342
+ * server.listen(8443);
2343
+ * ```
2344
+ * @since v8.4.0
2345
+ * @param onRequestHandler See `Compatibility API`
2346
+ */
2347
+ export function createSecureServer(
2348
+ onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2349
+ ): Http2SecureServer;
2350
+ export function createSecureServer(
2351
+ options: SecureServerOptions,
2352
+ onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void,
2353
+ ): Http2SecureServer;
2354
+ /**
2355
+ * Returns a `ClientHttp2Session` instance.
2356
+ *
2357
+ * ```js
2358
+ * const http2 = require('node:http2');
2359
+ * const client = http2.connect('https://localhost:1234');
2360
+ *
2361
+ * // Use the client
2362
+ *
2363
+ * client.close();
2364
+ * ```
2365
+ * @since v8.4.0
2366
+ * @param authority The remote HTTP/2 server to connect to. This must be in the form of a minimal, valid URL with the `http://` or `https://` prefix, host name, and IP port (if a non-default port
2367
+ * is used). Userinfo (user ID and password), path, querystring, and fragment details in the URL will be ignored.
2368
+ * @param listener Will be registered as a one-time listener of the {@link 'connect'} event.
2369
+ */
2370
+ export function connect(
2371
+ authority: string | url.URL,
2372
+ listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
2373
+ ): ClientHttp2Session;
2374
+ export function connect(
2375
+ authority: string | url.URL,
2376
+ options?: ClientSessionOptions | SecureClientSessionOptions,
2377
+ listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,
2378
+ ): ClientHttp2Session;
2379
+ }
2380
+ declare module "node:http2" {
2381
+ export * from "http2";
2382
+ }