rahad-media-downloader 2.1.12 → 2.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. package/.cache/replit/modules/nodejs-20.res +1 -0
  2. package/.cache/replit/modules/replit.res +1 -0
  3. package/.cache/typescript/5.4/node_modules/.package-lock.json +185 -0
  4. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +21 -0
  5. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +48 -0
  6. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +29 -0
  7. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +35 -0
  8. package/.cache/typescript/5.4/node_modules/@types/domhandler/LICENSE +21 -0
  9. package/.cache/typescript/5.4/node_modules/@types/domhandler/README.md +92 -0
  10. package/.cache/typescript/5.4/node_modules/@types/domhandler/index.d.ts +73 -0
  11. package/.cache/typescript/5.4/node_modules/@types/domhandler/package.json +25 -0
  12. package/.cache/typescript/5.4/node_modules/@types/domutils/LICENSE +21 -0
  13. package/.cache/typescript/5.4/node_modules/@types/domutils/README.md +15 -0
  14. package/.cache/typescript/5.4/node_modules/@types/domutils/index.d.ts +124 -0
  15. package/.cache/typescript/5.4/node_modules/@types/domutils/package.json +27 -0
  16. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/LICENSE +21 -0
  17. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/README.md +15 -0
  18. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/index.d.ts +120 -0
  19. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/package.json +45 -0
  20. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
  21. package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
  22. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
  23. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
  24. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
  25. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
  26. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1542 -0
  27. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
  29. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
  30. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4522 -0
  31. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
  32. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +545 -0
  33. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +473 -0
  34. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +853 -0
  35. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
  36. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
  37. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +884 -0
  38. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
  39. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
  40. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +411 -0
  41. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
  42. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1889 -0
  43. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
  44. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
  45. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
  46. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
  47. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
  48. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +996 -0
  49. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
  50. package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
  51. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
  52. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +645 -0
  53. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1747 -0
  54. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
  55. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
  56. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
  57. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
  58. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
  59. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
  60. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
  61. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
  62. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
  63. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
  64. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
  65. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1470 -0
  66. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
  67. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
  68. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
  69. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
  70. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
  71. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +944 -0
  72. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2276 -0
  73. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +764 -0
  74. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +921 -0
  75. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
  76. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +691 -0
  77. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
  78. package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +21 -0
  79. package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +15 -0
  80. package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +32 -0
  81. package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +238 -0
  82. package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +83 -0
  83. package/.cache/typescript/5.4/node_modules/@types/qs/LICENSE +21 -0
  84. package/.cache/typescript/5.4/node_modules/@types/qs/README.md +15 -0
  85. package/.cache/typescript/5.4/node_modules/@types/qs/index.d.ts +79 -0
  86. package/.cache/typescript/5.4/node_modules/@types/qs/package.json +65 -0
  87. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +21 -0
  88. package/.cache/typescript/5.4/node_modules/@types/request/README.md +15 -0
  89. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +395 -0
  90. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +19 -0
  91. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +350 -0
  92. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +350 -0
  93. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +51 -0
  94. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +2 -0
  95. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +483 -0
  96. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +10 -0
  97. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +68 -0
  98. package/.cache/typescript/5.4/node_modules/@types/request/package.json +70 -0
  99. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +21 -0
  100. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +15 -0
  101. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +321 -0
  102. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +35 -0
  103. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +21 -0
  104. package/.cache/typescript/5.4/node_modules/asynckit/README.md +233 -0
  105. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +76 -0
  106. package/.cache/typescript/5.4/node_modules/asynckit/index.js +6 -0
  107. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +29 -0
  108. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +34 -0
  109. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +26 -0
  110. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +75 -0
  111. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  112. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +25 -0
  113. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +25 -0
  114. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  115. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +37 -0
  116. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +141 -0
  117. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +29 -0
  118. package/.cache/typescript/5.4/node_modules/asynckit/package.json +63 -0
  119. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +43 -0
  120. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +17 -0
  121. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +75 -0
  122. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +21 -0
  123. package/.cache/typescript/5.4/node_modules/combined-stream/License +19 -0
  124. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +138 -0
  125. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +208 -0
  126. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +25 -0
  127. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +17 -0
  128. package/.cache/typescript/5.4/node_modules/delayed-stream/License +19 -0
  129. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +7 -0
  130. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +141 -0
  131. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  132. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +27 -0
  133. package/.cache/typescript/5.4/node_modules/domelementtype/LICENSE +11 -0
  134. package/.cache/typescript/5.4/node_modules/domelementtype/index.js +15 -0
  135. package/.cache/typescript/5.4/node_modules/domelementtype/package.json +16 -0
  136. package/.cache/typescript/5.4/node_modules/domelementtype/readme.md +1 -0
  137. package/.cache/typescript/5.4/node_modules/domhandler/.travis.yml +6 -0
  138. package/.cache/typescript/5.4/node_modules/domhandler/LICENSE +11 -0
  139. package/.cache/typescript/5.4/node_modules/domhandler/index.js +217 -0
  140. package/.cache/typescript/5.4/node_modules/domhandler/lib/element.js +20 -0
  141. package/.cache/typescript/5.4/node_modules/domhandler/lib/node.js +44 -0
  142. package/.cache/typescript/5.4/node_modules/domhandler/package.json +41 -0
  143. package/.cache/typescript/5.4/node_modules/domhandler/readme.md +116 -0
  144. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/01-basic.json +57 -0
  145. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  146. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  147. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  148. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  149. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  150. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  151. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  152. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  153. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  154. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  155. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  156. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  157. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  158. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  159. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  160. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  161. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  162. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  163. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  164. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  165. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  166. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/23-dom-lvl1.json +131 -0
  167. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/24-with-start-indices.json +85 -0
  168. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/25-with-end-indices.json +86 -0
  169. package/.cache/typescript/5.4/node_modules/domhandler/test/tests.js +60 -0
  170. package/.cache/typescript/5.4/node_modules/form-data/License +19 -0
  171. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +358 -0
  172. package/.cache/typescript/5.4/node_modules/form-data/Readme.md +358 -0
  173. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +62 -0
  174. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +2 -0
  175. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +501 -0
  176. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +10 -0
  177. package/.cache/typescript/5.4/node_modules/form-data/package.json +68 -0
  178. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +507 -0
  179. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +23 -0
  180. package/.cache/typescript/5.4/node_modules/mime-db/README.md +100 -0
  181. package/.cache/typescript/5.4/node_modules/mime-db/db.json +8519 -0
  182. package/.cache/typescript/5.4/node_modules/mime-db/index.js +12 -0
  183. package/.cache/typescript/5.4/node_modules/mime-db/package.json +60 -0
  184. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +397 -0
  185. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +23 -0
  186. package/.cache/typescript/5.4/node_modules/mime-types/README.md +113 -0
  187. package/.cache/typescript/5.4/node_modules/mime-types/index.js +188 -0
  188. package/.cache/typescript/5.4/node_modules/mime-types/package.json +44 -0
  189. package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
  190. package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
  191. package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
  192. package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
  193. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
  194. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
  195. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
  196. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
  197. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
  198. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
  199. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
  200. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
  201. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  202. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
  203. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
  204. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
  205. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
  206. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
  207. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
  208. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  209. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
  210. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
  211. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
  212. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
  213. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
  214. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
  215. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
  216. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
  217. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  218. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
  219. package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
  220. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
  221. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
  222. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
  223. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
  224. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
  225. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
  226. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
  227. package/.cache/typescript/5.4/package-lock.json +197 -0
  228. package/.cache/typescript/5.4/package.json +1 -0
  229. package/README.md +61 -2
  230. package/index.js +1 -1
  231. package/package.json +11 -2
  232. package/.cache/replit/modules/nodejs-20:v36-20240502-f4453db.res +0 -1
  233. package/.cache/replit/modules/replit:v9-20240429-0325cbb.res +0 -1
@@ -0,0 +1,1889 @@
1
+ /**
2
+ * To use the HTTP server and client one must `require('node:http')`.
3
+ *
4
+ * The HTTP interfaces in Node.js are designed to support many features
5
+ * of the protocol which have been traditionally difficult to use.
6
+ * In particular, large, possibly chunk-encoded, messages. The interface is
7
+ * careful to never buffer entire requests or responses, so the
8
+ * user is able to stream data.
9
+ *
10
+ * HTTP message headers are represented by an object like this:
11
+ *
12
+ * ```json
13
+ * { "content-length": "123",
14
+ * "content-type": "text/plain",
15
+ * "connection": "keep-alive",
16
+ * "host": "example.com",
17
+ * "accept": "*" }
18
+ * ```
19
+ *
20
+ * Keys are lowercased. Values are not modified.
21
+ *
22
+ * In order to support the full spectrum of possible HTTP applications, the Node.js
23
+ * HTTP API is very low-level. It deals with stream handling and message
24
+ * parsing only. It parses a message into headers and body but it does not
25
+ * parse the actual headers or the body.
26
+ *
27
+ * See `message.headers` for details on how duplicate headers are handled.
28
+ *
29
+ * The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For
30
+ * example, the previous message header object might have a `rawHeaders`list like the following:
31
+ *
32
+ * ```js
33
+ * [ 'ConTent-Length', '123456',
34
+ * 'content-LENGTH', '123',
35
+ * 'content-type', 'text/plain',
36
+ * 'CONNECTION', 'keep-alive',
37
+ * 'Host', 'example.com',
38
+ * 'accepT', '*' ]
39
+ * ```
40
+ * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/http.js)
41
+ */
42
+ declare module "http" {
43
+ import * as stream from "node:stream";
44
+ import { URL } from "node:url";
45
+ import { LookupOptions } from "node:dns";
46
+ import { EventEmitter } from "node:events";
47
+ import { LookupFunction, Server as NetServer, Socket, TcpSocketConnectOpts } from "node:net";
48
+ // incoming headers will never contain number
49
+ interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
50
+ accept?: string | undefined;
51
+ "accept-language"?: string | undefined;
52
+ "accept-patch"?: string | undefined;
53
+ "accept-ranges"?: string | undefined;
54
+ "access-control-allow-credentials"?: string | undefined;
55
+ "access-control-allow-headers"?: string | undefined;
56
+ "access-control-allow-methods"?: string | undefined;
57
+ "access-control-allow-origin"?: string | undefined;
58
+ "access-control-expose-headers"?: string | undefined;
59
+ "access-control-max-age"?: string | undefined;
60
+ "access-control-request-headers"?: string | undefined;
61
+ "access-control-request-method"?: string | undefined;
62
+ age?: string | undefined;
63
+ allow?: string | undefined;
64
+ "alt-svc"?: string | undefined;
65
+ authorization?: string | undefined;
66
+ "cache-control"?: string | undefined;
67
+ connection?: string | undefined;
68
+ "content-disposition"?: string | undefined;
69
+ "content-encoding"?: string | undefined;
70
+ "content-language"?: string | undefined;
71
+ "content-length"?: string | undefined;
72
+ "content-location"?: string | undefined;
73
+ "content-range"?: string | undefined;
74
+ "content-type"?: string | undefined;
75
+ cookie?: string | undefined;
76
+ date?: string | undefined;
77
+ etag?: string | undefined;
78
+ expect?: string | undefined;
79
+ expires?: string | undefined;
80
+ forwarded?: string | undefined;
81
+ from?: string | undefined;
82
+ host?: string | undefined;
83
+ "if-match"?: string | undefined;
84
+ "if-modified-since"?: string | undefined;
85
+ "if-none-match"?: string | undefined;
86
+ "if-unmodified-since"?: string | undefined;
87
+ "last-modified"?: string | undefined;
88
+ location?: string | undefined;
89
+ origin?: string | undefined;
90
+ pragma?: string | undefined;
91
+ "proxy-authenticate"?: string | undefined;
92
+ "proxy-authorization"?: string | undefined;
93
+ "public-key-pins"?: string | undefined;
94
+ range?: string | undefined;
95
+ referer?: string | undefined;
96
+ "retry-after"?: string | undefined;
97
+ "sec-websocket-accept"?: string | undefined;
98
+ "sec-websocket-extensions"?: string | undefined;
99
+ "sec-websocket-key"?: string | undefined;
100
+ "sec-websocket-protocol"?: string | undefined;
101
+ "sec-websocket-version"?: string | undefined;
102
+ "set-cookie"?: string[] | undefined;
103
+ "strict-transport-security"?: string | undefined;
104
+ tk?: string | undefined;
105
+ trailer?: string | undefined;
106
+ "transfer-encoding"?: string | undefined;
107
+ upgrade?: string | undefined;
108
+ "user-agent"?: string | undefined;
109
+ vary?: string | undefined;
110
+ via?: string | undefined;
111
+ warning?: string | undefined;
112
+ "www-authenticate"?: string | undefined;
113
+ }
114
+ // outgoing headers allows numbers (as they are converted internally to strings)
115
+ type OutgoingHttpHeader = number | string | string[];
116
+ interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {
117
+ accept?: string | string[] | undefined;
118
+ "accept-charset"?: string | string[] | undefined;
119
+ "accept-encoding"?: string | string[] | undefined;
120
+ "accept-language"?: string | string[] | undefined;
121
+ "accept-ranges"?: string | undefined;
122
+ "access-control-allow-credentials"?: string | undefined;
123
+ "access-control-allow-headers"?: string | undefined;
124
+ "access-control-allow-methods"?: string | undefined;
125
+ "access-control-allow-origin"?: string | undefined;
126
+ "access-control-expose-headers"?: string | undefined;
127
+ "access-control-max-age"?: string | undefined;
128
+ "access-control-request-headers"?: string | undefined;
129
+ "access-control-request-method"?: string | undefined;
130
+ age?: string | undefined;
131
+ allow?: string | undefined;
132
+ authorization?: string | undefined;
133
+ "cache-control"?: string | undefined;
134
+ "cdn-cache-control"?: string | undefined;
135
+ connection?: string | string[] | undefined;
136
+ "content-disposition"?: string | undefined;
137
+ "content-encoding"?: string | undefined;
138
+ "content-language"?: string | undefined;
139
+ "content-length"?: string | number | undefined;
140
+ "content-location"?: string | undefined;
141
+ "content-range"?: string | undefined;
142
+ "content-security-policy"?: string | undefined;
143
+ "content-security-policy-report-only"?: string | undefined;
144
+ cookie?: string | string[] | undefined;
145
+ dav?: string | string[] | undefined;
146
+ dnt?: string | undefined;
147
+ date?: string | undefined;
148
+ etag?: string | undefined;
149
+ expect?: string | undefined;
150
+ expires?: string | undefined;
151
+ forwarded?: string | undefined;
152
+ from?: string | undefined;
153
+ host?: string | undefined;
154
+ "if-match"?: string | undefined;
155
+ "if-modified-since"?: string | undefined;
156
+ "if-none-match"?: string | undefined;
157
+ "if-range"?: string | undefined;
158
+ "if-unmodified-since"?: string | undefined;
159
+ "last-modified"?: string | undefined;
160
+ link?: string | string[] | undefined;
161
+ location?: string | undefined;
162
+ "max-forwards"?: string | undefined;
163
+ origin?: string | undefined;
164
+ prgama?: string | string[] | undefined;
165
+ "proxy-authenticate"?: string | string[] | undefined;
166
+ "proxy-authorization"?: string | undefined;
167
+ "public-key-pins"?: string | undefined;
168
+ "public-key-pins-report-only"?: string | undefined;
169
+ range?: string | undefined;
170
+ referer?: string | undefined;
171
+ "referrer-policy"?: string | undefined;
172
+ refresh?: string | undefined;
173
+ "retry-after"?: string | undefined;
174
+ "sec-websocket-accept"?: string | undefined;
175
+ "sec-websocket-extensions"?: string | string[] | undefined;
176
+ "sec-websocket-key"?: string | undefined;
177
+ "sec-websocket-protocol"?: string | string[] | undefined;
178
+ "sec-websocket-version"?: string | undefined;
179
+ server?: string | undefined;
180
+ "set-cookie"?: string | string[] | undefined;
181
+ "strict-transport-security"?: string | undefined;
182
+ te?: string | undefined;
183
+ trailer?: string | undefined;
184
+ "transfer-encoding"?: string | undefined;
185
+ "user-agent"?: string | undefined;
186
+ upgrade?: string | undefined;
187
+ "upgrade-insecure-requests"?: string | undefined;
188
+ vary?: string | undefined;
189
+ via?: string | string[] | undefined;
190
+ warning?: string | undefined;
191
+ "www-authenticate"?: string | string[] | undefined;
192
+ "x-content-type-options"?: string | undefined;
193
+ "x-dns-prefetch-control"?: string | undefined;
194
+ "x-frame-options"?: string | undefined;
195
+ "x-xss-protection"?: string | undefined;
196
+ }
197
+ interface ClientRequestArgs {
198
+ _defaultAgent?: Agent | undefined;
199
+ agent?: Agent | boolean | undefined;
200
+ auth?: string | null | undefined;
201
+ createConnection?:
202
+ | ((
203
+ options: ClientRequestArgs,
204
+ oncreate: (err: Error | null, socket: stream.Duplex) => void,
205
+ ) => stream.Duplex | null | undefined)
206
+ | undefined;
207
+ defaultPort?: number | string | undefined;
208
+ family?: number | undefined;
209
+ headers?: OutgoingHttpHeaders | undefined;
210
+ hints?: LookupOptions["hints"];
211
+ host?: string | null | undefined;
212
+ hostname?: string | null | undefined;
213
+ insecureHTTPParser?: boolean | undefined;
214
+ localAddress?: string | undefined;
215
+ localPort?: number | undefined;
216
+ lookup?: LookupFunction | undefined;
217
+ /**
218
+ * @default 16384
219
+ */
220
+ maxHeaderSize?: number | undefined;
221
+ method?: string | undefined;
222
+ path?: string | null | undefined;
223
+ port?: number | string | null | undefined;
224
+ protocol?: string | null | undefined;
225
+ setHost?: boolean | undefined;
226
+ signal?: AbortSignal | undefined;
227
+ socketPath?: string | undefined;
228
+ timeout?: number | undefined;
229
+ uniqueHeaders?: Array<string | string[]> | undefined;
230
+ joinDuplicateHeaders?: boolean;
231
+ }
232
+ interface ServerOptions<
233
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
234
+ Response extends typeof ServerResponse = typeof ServerResponse,
235
+ > {
236
+ /**
237
+ * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
238
+ */
239
+ IncomingMessage?: Request | undefined;
240
+ /**
241
+ * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`.
242
+ */
243
+ ServerResponse?: Response | undefined;
244
+ /**
245
+ * Sets the timeout value in milliseconds for receiving the entire request from the client.
246
+ * @see Server.requestTimeout for more information.
247
+ * @default 300000
248
+ * @since v18.0.0
249
+ */
250
+ requestTimeout?: number | undefined;
251
+ /**
252
+ * It joins the field line values of multiple headers in a request with `, ` instead of discarding the duplicates.
253
+ * @default false
254
+ * @since v18.14.0
255
+ */
256
+ joinDuplicateHeaders?: boolean;
257
+ /**
258
+ * The number of milliseconds of inactivity a server needs to wait for additional incoming data,
259
+ * after it has finished writing the last response, before a socket will be destroyed.
260
+ * @see Server.keepAliveTimeout for more information.
261
+ * @default 5000
262
+ * @since v18.0.0
263
+ */
264
+ keepAliveTimeout?: number | undefined;
265
+ /**
266
+ * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
267
+ * @default 30000
268
+ */
269
+ connectionsCheckingInterval?: number | undefined;
270
+ /**
271
+ * Optionally overrides all `socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
272
+ * This affects `highWaterMark` property of both `IncomingMessage` and `ServerResponse`.
273
+ * Default: @see stream.getDefaultHighWaterMark().
274
+ * @since v20.1.0
275
+ */
276
+ highWaterMark?: number | undefined;
277
+ /**
278
+ * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`.
279
+ * Using the insecure parser should be avoided.
280
+ * See --insecure-http-parser for more information.
281
+ * @default false
282
+ */
283
+ insecureHTTPParser?: boolean | undefined;
284
+ /**
285
+ * Optionally overrides the value of
286
+ * `--max-http-header-size` for requests received by this server, i.e.
287
+ * the maximum length of request headers in bytes.
288
+ * @default 16384
289
+ * @since v13.3.0
290
+ */
291
+ maxHeaderSize?: number | undefined;
292
+ /**
293
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
294
+ * @default true
295
+ * @since v16.5.0
296
+ */
297
+ noDelay?: boolean | undefined;
298
+ /**
299
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
300
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
301
+ * @default false
302
+ * @since v16.5.0
303
+ */
304
+ keepAlive?: boolean | undefined;
305
+ /**
306
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
307
+ * @default 0
308
+ * @since v16.5.0
309
+ */
310
+ keepAliveInitialDelay?: number | undefined;
311
+ /**
312
+ * A list of response headers that should be sent only once.
313
+ * If the header's value is an array, the items will be joined using `; `.
314
+ */
315
+ uniqueHeaders?: Array<string | string[]> | undefined;
316
+ }
317
+ type RequestListener<
318
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
319
+ Response extends typeof ServerResponse = typeof ServerResponse,
320
+ > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
321
+ /**
322
+ * @since v0.1.17
323
+ */
324
+ class Server<
325
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
326
+ Response extends typeof ServerResponse = typeof ServerResponse,
327
+ > extends NetServer {
328
+ constructor(requestListener?: RequestListener<Request, Response>);
329
+ constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
330
+ /**
331
+ * Sets the timeout value for sockets, and emits a `'timeout'` event on
332
+ * the Server object, passing the socket as an argument, if a timeout
333
+ * occurs.
334
+ *
335
+ * If there is a `'timeout'` event listener on the Server object, then it
336
+ * will be called with the timed-out socket as an argument.
337
+ *
338
+ * By default, the Server does not timeout sockets. However, if a callback
339
+ * is assigned to the Server's `'timeout'` event, timeouts must be handled
340
+ * explicitly.
341
+ * @since v0.9.12
342
+ * @param [msecs=0 (no timeout)]
343
+ */
344
+ setTimeout(msecs?: number, callback?: () => void): this;
345
+ setTimeout(callback: () => void): this;
346
+ /**
347
+ * Limits maximum incoming headers count. If set to 0, no limit will be applied.
348
+ * @since v0.7.0
349
+ */
350
+ maxHeadersCount: number | null;
351
+ /**
352
+ * The maximum number of requests socket can handle
353
+ * before closing keep alive connection.
354
+ *
355
+ * A value of `0` will disable the limit.
356
+ *
357
+ * When the limit is reached it will set the `Connection` header value to `close`,
358
+ * but will not actually close the connection, subsequent requests sent
359
+ * after the limit is reached will get `503 Service Unavailable` as a response.
360
+ * @since v16.10.0
361
+ */
362
+ maxRequestsPerSocket: number | null;
363
+ /**
364
+ * The number of milliseconds of inactivity before a socket is presumed
365
+ * to have timed out.
366
+ *
367
+ * A value of `0` will disable the timeout behavior on incoming connections.
368
+ *
369
+ * The socket timeout logic is set up on connection, so changing this
370
+ * value only affects new connections to the server, not any existing connections.
371
+ * @since v0.9.12
372
+ */
373
+ timeout: number;
374
+ /**
375
+ * Limit the amount of time the parser will wait to receive the complete HTTP
376
+ * headers.
377
+ *
378
+ * If the timeout expires, the server responds with status 408 without
379
+ * forwarding the request to the request listener and then closes the connection.
380
+ *
381
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
382
+ * potential Denial-of-Service attacks in case the server is deployed without a
383
+ * reverse proxy in front.
384
+ * @since v11.3.0, v10.14.0
385
+ */
386
+ headersTimeout: number;
387
+ /**
388
+ * The number of milliseconds of inactivity a server needs to wait for additional
389
+ * incoming data, after it has finished writing the last response, before a socket
390
+ * will be destroyed. If the server receives new data before the keep-alive
391
+ * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
392
+ *
393
+ * A value of `0` will disable the keep-alive timeout behavior on incoming
394
+ * connections.
395
+ * A value of `0` makes the http server behave similarly to Node.js versions prior
396
+ * to 8.0.0, which did not have a keep-alive timeout.
397
+ *
398
+ * The socket timeout logic is set up on connection, so changing this value only
399
+ * affects new connections to the server, not any existing connections.
400
+ * @since v8.0.0
401
+ */
402
+ keepAliveTimeout: number;
403
+ /**
404
+ * Sets the timeout value in milliseconds for receiving the entire request from
405
+ * the client.
406
+ *
407
+ * If the timeout expires, the server responds with status 408 without
408
+ * forwarding the request to the request listener and then closes the connection.
409
+ *
410
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
411
+ * potential Denial-of-Service attacks in case the server is deployed without a
412
+ * reverse proxy in front.
413
+ * @since v14.11.0
414
+ */
415
+ requestTimeout: number;
416
+ /**
417
+ * Closes all connections connected to this server.
418
+ * @since v18.2.0
419
+ */
420
+ closeAllConnections(): void;
421
+ /**
422
+ * Closes all connections connected to this server which are not sending a request
423
+ * or waiting for a response.
424
+ * @since v18.2.0
425
+ */
426
+ closeIdleConnections(): void;
427
+ addListener(event: string, listener: (...args: any[]) => void): this;
428
+ addListener(event: "close", listener: () => void): this;
429
+ addListener(event: "connection", listener: (socket: Socket) => void): this;
430
+ addListener(event: "error", listener: (err: Error) => void): this;
431
+ addListener(event: "listening", listener: () => void): this;
432
+ addListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
433
+ addListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
434
+ addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
435
+ addListener(
436
+ event: "connect",
437
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
438
+ ): this;
439
+ addListener(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
440
+ addListener(event: "request", listener: RequestListener<Request, Response>): this;
441
+ addListener(
442
+ event: "upgrade",
443
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
444
+ ): this;
445
+ emit(event: string, ...args: any[]): boolean;
446
+ emit(event: "close"): boolean;
447
+ emit(event: "connection", socket: Socket): boolean;
448
+ emit(event: "error", err: Error): boolean;
449
+ emit(event: "listening"): boolean;
450
+ emit(
451
+ event: "checkContinue",
452
+ req: InstanceType<Request>,
453
+ res: InstanceType<Response> & { req: InstanceType<Request> },
454
+ ): boolean;
455
+ emit(
456
+ event: "checkExpectation",
457
+ req: InstanceType<Request>,
458
+ res: InstanceType<Response> & { req: InstanceType<Request> },
459
+ ): boolean;
460
+ emit(event: "clientError", err: Error, socket: stream.Duplex): boolean;
461
+ emit(event: "connect", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
462
+ emit(event: "dropRequest", req: InstanceType<Request>, socket: stream.Duplex): boolean;
463
+ emit(
464
+ event: "request",
465
+ req: InstanceType<Request>,
466
+ res: InstanceType<Response> & { req: InstanceType<Request> },
467
+ ): boolean;
468
+ emit(event: "upgrade", req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
469
+ on(event: string, listener: (...args: any[]) => void): this;
470
+ on(event: "close", listener: () => void): this;
471
+ on(event: "connection", listener: (socket: Socket) => void): this;
472
+ on(event: "error", listener: (err: Error) => void): this;
473
+ on(event: "listening", listener: () => void): this;
474
+ on(event: "checkContinue", listener: RequestListener<Request, Response>): this;
475
+ on(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
476
+ on(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
477
+ on(event: "connect", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
478
+ on(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
479
+ on(event: "request", listener: RequestListener<Request, Response>): this;
480
+ on(event: "upgrade", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
481
+ once(event: string, listener: (...args: any[]) => void): this;
482
+ once(event: "close", listener: () => void): this;
483
+ once(event: "connection", listener: (socket: Socket) => void): this;
484
+ once(event: "error", listener: (err: Error) => void): this;
485
+ once(event: "listening", listener: () => void): this;
486
+ once(event: "checkContinue", listener: RequestListener<Request, Response>): this;
487
+ once(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
488
+ once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
489
+ once(
490
+ event: "connect",
491
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
492
+ ): this;
493
+ once(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
494
+ once(event: "request", listener: RequestListener<Request, Response>): this;
495
+ once(
496
+ event: "upgrade",
497
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
498
+ ): this;
499
+ prependListener(event: string, listener: (...args: any[]) => void): this;
500
+ prependListener(event: "close", listener: () => void): this;
501
+ prependListener(event: "connection", listener: (socket: Socket) => void): this;
502
+ prependListener(event: "error", listener: (err: Error) => void): this;
503
+ prependListener(event: "listening", listener: () => void): this;
504
+ prependListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
505
+ prependListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
506
+ prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
507
+ prependListener(
508
+ event: "connect",
509
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
510
+ ): this;
511
+ prependListener(
512
+ event: "dropRequest",
513
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
514
+ ): this;
515
+ prependListener(event: "request", listener: RequestListener<Request, Response>): this;
516
+ prependListener(
517
+ event: "upgrade",
518
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
519
+ ): this;
520
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
521
+ prependOnceListener(event: "close", listener: () => void): this;
522
+ prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
523
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
524
+ prependOnceListener(event: "listening", listener: () => void): this;
525
+ prependOnceListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
526
+ prependOnceListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
527
+ prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
528
+ prependOnceListener(
529
+ event: "connect",
530
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
531
+ ): this;
532
+ prependOnceListener(
533
+ event: "dropRequest",
534
+ listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
535
+ ): this;
536
+ prependOnceListener(event: "request", listener: RequestListener<Request, Response>): this;
537
+ prependOnceListener(
538
+ event: "upgrade",
539
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
540
+ ): this;
541
+ }
542
+ /**
543
+ * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract outgoing message from
544
+ * the perspective of the participants of an HTTP transaction.
545
+ * @since v0.1.17
546
+ */
547
+ class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
548
+ readonly req: Request;
549
+ chunkedEncoding: boolean;
550
+ shouldKeepAlive: boolean;
551
+ useChunkedEncodingByDefault: boolean;
552
+ sendDate: boolean;
553
+ /**
554
+ * @deprecated Use `writableEnded` instead.
555
+ */
556
+ finished: boolean;
557
+ /**
558
+ * Read-only. `true` if the headers were sent, otherwise `false`.
559
+ * @since v0.9.3
560
+ */
561
+ readonly headersSent: boolean;
562
+ /**
563
+ * Alias of `outgoingMessage.socket`.
564
+ * @since v0.3.0
565
+ * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
566
+ */
567
+ readonly connection: Socket | null;
568
+ /**
569
+ * Reference to the underlying socket. Usually, users will not want to access
570
+ * this property.
571
+ *
572
+ * After calling `outgoingMessage.end()`, this property will be nulled.
573
+ * @since v0.3.0
574
+ */
575
+ readonly socket: Socket | null;
576
+ constructor();
577
+ /**
578
+ * Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
579
+ * @since v0.9.12
580
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
581
+ */
582
+ setTimeout(msecs: number, callback?: () => void): this;
583
+ /**
584
+ * Sets a single header value. If the header already exists in the to-be-sent
585
+ * headers, its value will be replaced. Use an array of strings to send multiple
586
+ * headers with the same name.
587
+ * @since v0.4.0
588
+ * @param name Header name
589
+ * @param value Header value
590
+ */
591
+ setHeader(name: string, value: number | string | readonly string[]): this;
592
+ /**
593
+ * Append a single header value to the header object.
594
+ *
595
+ * If the value is an array, this is equivalent to calling this method multiple
596
+ * times.
597
+ *
598
+ * If there were no previous values for the header, this is equivalent to calling `outgoingMessage.setHeader(name, value)`.
599
+ *
600
+ * Depending of the value of `options.uniqueHeaders` when the client request or the
601
+ * server were created, this will end up in the header being sent multiple times or
602
+ * a single time with values joined using `; `.
603
+ * @since v18.3.0, v16.17.0
604
+ * @param name Header name
605
+ * @param value Header value
606
+ */
607
+ appendHeader(name: string, value: string | readonly string[]): this;
608
+ /**
609
+ * Gets the value of the HTTP header with the given name. If that header is not
610
+ * set, the returned value will be `undefined`.
611
+ * @since v0.4.0
612
+ * @param name Name of header
613
+ */
614
+ getHeader(name: string): number | string | string[] | undefined;
615
+ /**
616
+ * Returns a shallow copy of the current outgoing headers. Since a shallow
617
+ * copy is used, array values may be mutated without additional calls to
618
+ * various header-related HTTP module methods. The keys of the returned
619
+ * object are the header names and the values are the respective header
620
+ * values. All header names are lowercase.
621
+ *
622
+ * The object returned by the `outgoingMessage.getHeaders()` method does
623
+ * not prototypically inherit from the JavaScript `Object`. This means that
624
+ * typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
625
+ * and others are not defined and will not work.
626
+ *
627
+ * ```js
628
+ * outgoingMessage.setHeader('Foo', 'bar');
629
+ * outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
630
+ *
631
+ * const headers = outgoingMessage.getHeaders();
632
+ * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
633
+ * ```
634
+ * @since v7.7.0
635
+ */
636
+ getHeaders(): OutgoingHttpHeaders;
637
+ /**
638
+ * Returns an array containing the unique names of the current outgoing headers.
639
+ * All names are lowercase.
640
+ * @since v7.7.0
641
+ */
642
+ getHeaderNames(): string[];
643
+ /**
644
+ * Returns `true` if the header identified by `name` is currently set in the
645
+ * outgoing headers. The header name is case-insensitive.
646
+ *
647
+ * ```js
648
+ * const hasContentType = outgoingMessage.hasHeader('content-type');
649
+ * ```
650
+ * @since v7.7.0
651
+ */
652
+ hasHeader(name: string): boolean;
653
+ /**
654
+ * Removes a header that is queued for implicit sending.
655
+ *
656
+ * ```js
657
+ * outgoingMessage.removeHeader('Content-Encoding');
658
+ * ```
659
+ * @since v0.4.0
660
+ * @param name Header name
661
+ */
662
+ removeHeader(name: string): void;
663
+ /**
664
+ * Adds HTTP trailers (headers but at the end of the message) to the message.
665
+ *
666
+ * Trailers will **only** be emitted if the message is chunked encoded. If not,
667
+ * the trailers will be silently discarded.
668
+ *
669
+ * HTTP requires the `Trailer` header to be sent to emit trailers,
670
+ * with a list of header field names in its value, e.g.
671
+ *
672
+ * ```js
673
+ * message.writeHead(200, { 'Content-Type': 'text/plain',
674
+ * 'Trailer': 'Content-MD5' });
675
+ * message.write(fileData);
676
+ * message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
677
+ * message.end();
678
+ * ```
679
+ *
680
+ * Attempting to set a header field name or value that contains invalid characters
681
+ * will result in a `TypeError` being thrown.
682
+ * @since v0.3.0
683
+ */
684
+ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
685
+ /**
686
+ * Flushes the message headers.
687
+ *
688
+ * For efficiency reason, Node.js normally buffers the message headers
689
+ * until `outgoingMessage.end()` is called or the first chunk of message data
690
+ * is written. It then tries to pack the headers and data into a single TCP
691
+ * packet.
692
+ *
693
+ * It is usually desired (it saves a TCP round-trip), but not when the first
694
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the message.
695
+ * @since v1.6.0
696
+ */
697
+ flushHeaders(): void;
698
+ }
699
+ /**
700
+ * This object is created internally by an HTTP server, not by the user. It is
701
+ * passed as the second parameter to the `'request'` event.
702
+ * @since v0.1.17
703
+ */
704
+ class ServerResponse<Request extends IncomingMessage = IncomingMessage> extends OutgoingMessage<Request> {
705
+ /**
706
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
707
+ * this property controls the status code that will be sent to the client when
708
+ * the headers get flushed.
709
+ *
710
+ * ```js
711
+ * response.statusCode = 404;
712
+ * ```
713
+ *
714
+ * After response header was sent to the client, this property indicates the
715
+ * status code which was sent out.
716
+ * @since v0.4.0
717
+ */
718
+ statusCode: number;
719
+ /**
720
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
721
+ * this property controls the status message that will be sent to the client when
722
+ * the headers get flushed. If this is left as `undefined` then the standard
723
+ * message for the status code will be used.
724
+ *
725
+ * ```js
726
+ * response.statusMessage = 'Not found';
727
+ * ```
728
+ *
729
+ * After response header was sent to the client, this property indicates the
730
+ * status message which was sent out.
731
+ * @since v0.11.8
732
+ */
733
+ statusMessage: string;
734
+ /**
735
+ * If set to `true`, Node.js will check whether the `Content-Length`header value and the size of the body, in bytes, are equal.
736
+ * Mismatching the `Content-Length` header value will result
737
+ * in an `Error` being thrown, identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
738
+ * @since v18.10.0, v16.18.0
739
+ */
740
+ strictContentLength: boolean;
741
+ constructor(req: Request);
742
+ assignSocket(socket: Socket): void;
743
+ detachSocket(socket: Socket): void;
744
+ /**
745
+ * Sends an HTTP/1.1 100 Continue message to the client, indicating that
746
+ * the request body should be sent. See the `'checkContinue'` event on`Server`.
747
+ * @since v0.3.0
748
+ */
749
+ writeContinue(callback?: () => void): void;
750
+ /**
751
+ * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header,
752
+ * indicating that the user agent can preload/preconnect the linked resources.
753
+ * The `hints` is an object containing the values of headers to be sent with
754
+ * early hints message. The optional `callback` argument will be called when
755
+ * the response message has been written.
756
+ *
757
+ * **Example**
758
+ *
759
+ * ```js
760
+ * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
761
+ * response.writeEarlyHints({
762
+ * 'link': earlyHintsLink,
763
+ * });
764
+ *
765
+ * const earlyHintsLinks = [
766
+ * '</styles.css>; rel=preload; as=style',
767
+ * '</scripts.js>; rel=preload; as=script',
768
+ * ];
769
+ * response.writeEarlyHints({
770
+ * 'link': earlyHintsLinks,
771
+ * 'x-trace-id': 'id for diagnostics',
772
+ * });
773
+ *
774
+ * const earlyHintsCallback = () => console.log('early hints message sent');
775
+ * response.writeEarlyHints({
776
+ * 'link': earlyHintsLinks,
777
+ * }, earlyHintsCallback);
778
+ * ```
779
+ * @since v18.11.0
780
+ * @param hints An object containing the values of headers
781
+ * @param callback Will be called when the response message has been written
782
+ */
783
+ writeEarlyHints(hints: Record<string, string | string[]>, callback?: () => void): void;
784
+ /**
785
+ * Sends a response header to the request. The status code is a 3-digit HTTP
786
+ * status code, like `404`. The last argument, `headers`, are the response headers.
787
+ * Optionally one can give a human-readable `statusMessage` as the second
788
+ * argument.
789
+ *
790
+ * `headers` may be an `Array` where the keys and values are in the same list.
791
+ * It is _not_ a list of tuples. So, the even-numbered offsets are key values,
792
+ * and the odd-numbered offsets are the associated values. The array is in the same
793
+ * format as `request.rawHeaders`.
794
+ *
795
+ * Returns a reference to the `ServerResponse`, so that calls can be chained.
796
+ *
797
+ * ```js
798
+ * const body = 'hello world';
799
+ * response
800
+ * .writeHead(200, {
801
+ * 'Content-Length': Buffer.byteLength(body),
802
+ * 'Content-Type': 'text/plain',
803
+ * })
804
+ * .end(body);
805
+ * ```
806
+ *
807
+ * This method must only be called once on a message and it must
808
+ * be called before `response.end()` is called.
809
+ *
810
+ * If `response.write()` or `response.end()` are called before calling
811
+ * this, the implicit/mutable headers will be calculated and call this function.
812
+ *
813
+ * When headers have been set with `response.setHeader()`, they will be merged
814
+ * with any headers passed to `response.writeHead()`, with the headers passed
815
+ * to `response.writeHead()` given precedence.
816
+ *
817
+ * If this method is called and `response.setHeader()` has not been called,
818
+ * it will directly write the supplied header values onto the network channel
819
+ * without caching internally, and the `response.getHeader()` on the header
820
+ * will not yield the expected result. If progressive population of headers is
821
+ * desired with potential future retrieval and modification, use `response.setHeader()` instead.
822
+ *
823
+ * ```js
824
+ * // Returns content-type = text/plain
825
+ * const server = http.createServer((req, res) => {
826
+ * res.setHeader('Content-Type', 'text/html');
827
+ * res.setHeader('X-Foo', 'bar');
828
+ * res.writeHead(200, { 'Content-Type': 'text/plain' });
829
+ * res.end('ok');
830
+ * });
831
+ * ```
832
+ *
833
+ * `Content-Length` is read in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
834
+ * will check whether `Content-Length` and the length of the body which has
835
+ * been transmitted are equal or not.
836
+ *
837
+ * Attempting to set a header field name or value that contains invalid characters
838
+ * will result in a \[`Error`\]\[\] being thrown.
839
+ * @since v0.1.30
840
+ */
841
+ writeHead(
842
+ statusCode: number,
843
+ statusMessage?: string,
844
+ headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
845
+ ): this;
846
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
847
+ /**
848
+ * Sends a HTTP/1.1 102 Processing message to the client, indicating that
849
+ * the request body should be sent.
850
+ * @since v10.0.0
851
+ */
852
+ writeProcessing(): void;
853
+ }
854
+ interface InformationEvent {
855
+ statusCode: number;
856
+ statusMessage: string;
857
+ httpVersion: string;
858
+ httpVersionMajor: number;
859
+ httpVersionMinor: number;
860
+ headers: IncomingHttpHeaders;
861
+ rawHeaders: string[];
862
+ }
863
+ /**
864
+ * This object is created internally and returned from {@link request}. It
865
+ * represents an _in-progress_ request whose header has already been queued. The
866
+ * header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will
867
+ * be sent along with the first data chunk or when calling `request.end()`.
868
+ *
869
+ * To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response
870
+ * headers have been received. The `'response'` event is executed with one
871
+ * argument which is an instance of {@link IncomingMessage}.
872
+ *
873
+ * During the `'response'` event, one can add listeners to the
874
+ * response object; particularly to listen for the `'data'` event.
875
+ *
876
+ * If no `'response'` handler is added, then the response will be
877
+ * entirely discarded. However, if a `'response'` event handler is added,
878
+ * then the data from the response object **must** be consumed, either by
879
+ * calling `response.read()` whenever there is a `'readable'` event, or
880
+ * by adding a `'data'` handler, or by calling the `.resume()` method.
881
+ * Until the data is consumed, the `'end'` event will not fire. Also, until
882
+ * the data is read it will consume memory that can eventually lead to a
883
+ * 'process out of memory' error.
884
+ *
885
+ * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
886
+ *
887
+ * Set `Content-Length` header to limit the response body size.
888
+ * If `response.strictContentLength` is set to `true`, mismatching the`Content-Length` header value will result in an `Error` being thrown,
889
+ * identified by `code:``'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`.
890
+ *
891
+ * `Content-Length` value should be in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes.
892
+ * @since v0.1.17
893
+ */
894
+ class ClientRequest extends OutgoingMessage {
895
+ /**
896
+ * The `request.aborted` property will be `true` if the request has
897
+ * been aborted.
898
+ * @since v0.11.14
899
+ * @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
900
+ */
901
+ aborted: boolean;
902
+ /**
903
+ * The request host.
904
+ * @since v14.5.0, v12.19.0
905
+ */
906
+ host: string;
907
+ /**
908
+ * The request protocol.
909
+ * @since v14.5.0, v12.19.0
910
+ */
911
+ protocol: string;
912
+ /**
913
+ * When sending request through a keep-alive enabled agent, the underlying socket
914
+ * might be reused. But if server closes connection at unfortunate time, client
915
+ * may run into a 'ECONNRESET' error.
916
+ *
917
+ * ```js
918
+ * import http from 'node:http';
919
+ *
920
+ * // Server has a 5 seconds keep-alive timeout by default
921
+ * http
922
+ * .createServer((req, res) => {
923
+ * res.write('hello\n');
924
+ * res.end();
925
+ * })
926
+ * .listen(3000);
927
+ *
928
+ * setInterval(() => {
929
+ * // Adapting a keep-alive agent
930
+ * http.get('http://localhost:3000', { agent }, (res) => {
931
+ * res.on('data', (data) => {
932
+ * // Do nothing
933
+ * });
934
+ * });
935
+ * }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
936
+ * ```
937
+ *
938
+ * By marking a request whether it reused socket or not, we can do
939
+ * automatic error retry base on it.
940
+ *
941
+ * ```js
942
+ * import http from 'node:http';
943
+ * const agent = new http.Agent({ keepAlive: true });
944
+ *
945
+ * function retriableRequest() {
946
+ * const req = http
947
+ * .get('http://localhost:3000', { agent }, (res) => {
948
+ * // ...
949
+ * })
950
+ * .on('error', (err) => {
951
+ * // Check if retry is needed
952
+ * if (req.reusedSocket &#x26;&#x26; err.code === 'ECONNRESET') {
953
+ * retriableRequest();
954
+ * }
955
+ * });
956
+ * }
957
+ *
958
+ * retriableRequest();
959
+ * ```
960
+ * @since v13.0.0, v12.16.0
961
+ */
962
+ reusedSocket: boolean;
963
+ /**
964
+ * Limits maximum response headers count. If set to 0, no limit will be applied.
965
+ */
966
+ maxHeadersCount: number;
967
+ constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
968
+ /**
969
+ * The request method.
970
+ * @since v0.1.97
971
+ */
972
+ method: string;
973
+ /**
974
+ * The request path.
975
+ * @since v0.4.0
976
+ */
977
+ path: string;
978
+ /**
979
+ * Marks the request as aborting. Calling this will cause remaining data
980
+ * in the response to be dropped and the socket to be destroyed.
981
+ * @since v0.3.8
982
+ * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead.
983
+ */
984
+ abort(): void;
985
+ onSocket(socket: Socket): void;
986
+ /**
987
+ * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called.
988
+ * @since v0.5.9
989
+ * @param timeout Milliseconds before a request times out.
990
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event.
991
+ */
992
+ setTimeout(timeout: number, callback?: () => void): this;
993
+ /**
994
+ * Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called.
995
+ * @since v0.5.9
996
+ */
997
+ setNoDelay(noDelay?: boolean): void;
998
+ /**
999
+ * Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called.
1000
+ * @since v0.5.9
1001
+ */
1002
+ setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
1003
+ /**
1004
+ * Returns an array containing the unique names of the current outgoing raw
1005
+ * headers. Header names are returned with their exact casing being set.
1006
+ *
1007
+ * ```js
1008
+ * request.setHeader('Foo', 'bar');
1009
+ * request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
1010
+ *
1011
+ * const headerNames = request.getRawHeaderNames();
1012
+ * // headerNames === ['Foo', 'Set-Cookie']
1013
+ * ```
1014
+ * @since v15.13.0, v14.17.0
1015
+ */
1016
+ getRawHeaderNames(): string[];
1017
+ /**
1018
+ * @deprecated
1019
+ */
1020
+ addListener(event: "abort", listener: () => void): this;
1021
+ addListener(
1022
+ event: "connect",
1023
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1024
+ ): this;
1025
+ addListener(event: "continue", listener: () => void): this;
1026
+ addListener(event: "information", listener: (info: InformationEvent) => void): this;
1027
+ addListener(event: "response", listener: (response: IncomingMessage) => void): this;
1028
+ addListener(event: "socket", listener: (socket: Socket) => void): this;
1029
+ addListener(event: "timeout", listener: () => void): this;
1030
+ addListener(
1031
+ event: "upgrade",
1032
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1033
+ ): this;
1034
+ addListener(event: "close", listener: () => void): this;
1035
+ addListener(event: "drain", listener: () => void): this;
1036
+ addListener(event: "error", listener: (err: Error) => void): this;
1037
+ addListener(event: "finish", listener: () => void): this;
1038
+ addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1039
+ addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1040
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1041
+ /**
1042
+ * @deprecated
1043
+ */
1044
+ on(event: "abort", listener: () => void): this;
1045
+ on(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1046
+ on(event: "continue", listener: () => void): this;
1047
+ on(event: "information", listener: (info: InformationEvent) => void): this;
1048
+ on(event: "response", listener: (response: IncomingMessage) => void): this;
1049
+ on(event: "socket", listener: (socket: Socket) => void): this;
1050
+ on(event: "timeout", listener: () => void): this;
1051
+ on(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1052
+ on(event: "close", listener: () => void): this;
1053
+ on(event: "drain", listener: () => void): this;
1054
+ on(event: "error", listener: (err: Error) => void): this;
1055
+ on(event: "finish", listener: () => void): this;
1056
+ on(event: "pipe", listener: (src: stream.Readable) => void): this;
1057
+ on(event: "unpipe", listener: (src: stream.Readable) => void): this;
1058
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
1059
+ /**
1060
+ * @deprecated
1061
+ */
1062
+ once(event: "abort", listener: () => void): this;
1063
+ once(event: "connect", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1064
+ once(event: "continue", listener: () => void): this;
1065
+ once(event: "information", listener: (info: InformationEvent) => void): this;
1066
+ once(event: "response", listener: (response: IncomingMessage) => void): this;
1067
+ once(event: "socket", listener: (socket: Socket) => void): this;
1068
+ once(event: "timeout", listener: () => void): this;
1069
+ once(event: "upgrade", listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
1070
+ once(event: "close", listener: () => void): this;
1071
+ once(event: "drain", listener: () => void): this;
1072
+ once(event: "error", listener: (err: Error) => void): this;
1073
+ once(event: "finish", listener: () => void): this;
1074
+ once(event: "pipe", listener: (src: stream.Readable) => void): this;
1075
+ once(event: "unpipe", listener: (src: stream.Readable) => void): this;
1076
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
1077
+ /**
1078
+ * @deprecated
1079
+ */
1080
+ prependListener(event: "abort", listener: () => void): this;
1081
+ prependListener(
1082
+ event: "connect",
1083
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1084
+ ): this;
1085
+ prependListener(event: "continue", listener: () => void): this;
1086
+ prependListener(event: "information", listener: (info: InformationEvent) => void): this;
1087
+ prependListener(event: "response", listener: (response: IncomingMessage) => void): this;
1088
+ prependListener(event: "socket", listener: (socket: Socket) => void): this;
1089
+ prependListener(event: "timeout", listener: () => void): this;
1090
+ prependListener(
1091
+ event: "upgrade",
1092
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1093
+ ): this;
1094
+ prependListener(event: "close", listener: () => void): this;
1095
+ prependListener(event: "drain", listener: () => void): this;
1096
+ prependListener(event: "error", listener: (err: Error) => void): this;
1097
+ prependListener(event: "finish", listener: () => void): this;
1098
+ prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1099
+ prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1100
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1101
+ /**
1102
+ * @deprecated
1103
+ */
1104
+ prependOnceListener(event: "abort", listener: () => void): this;
1105
+ prependOnceListener(
1106
+ event: "connect",
1107
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1108
+ ): this;
1109
+ prependOnceListener(event: "continue", listener: () => void): this;
1110
+ prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this;
1111
+ prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this;
1112
+ prependOnceListener(event: "socket", listener: (socket: Socket) => void): this;
1113
+ prependOnceListener(event: "timeout", listener: () => void): this;
1114
+ prependOnceListener(
1115
+ event: "upgrade",
1116
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1117
+ ): this;
1118
+ prependOnceListener(event: "close", listener: () => void): this;
1119
+ prependOnceListener(event: "drain", listener: () => void): this;
1120
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
1121
+ prependOnceListener(event: "finish", listener: () => void): this;
1122
+ prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1123
+ prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1124
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1125
+ }
1126
+ /**
1127
+ * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
1128
+ * access response
1129
+ * status, headers, and data.
1130
+ *
1131
+ * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
1132
+ * parse and emit the incoming HTTP headers and payload, as the underlying socket
1133
+ * may be reused multiple times in case of keep-alive.
1134
+ * @since v0.1.17
1135
+ */
1136
+ class IncomingMessage extends stream.Readable {
1137
+ constructor(socket: Socket);
1138
+ /**
1139
+ * The `message.aborted` property will be `true` if the request has
1140
+ * been aborted.
1141
+ * @since v10.1.0
1142
+ * @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
1143
+ */
1144
+ aborted: boolean;
1145
+ /**
1146
+ * In case of server request, the HTTP version sent by the client. In the case of
1147
+ * client response, the HTTP version of the connected-to server.
1148
+ * Probably either `'1.1'` or `'1.0'`.
1149
+ *
1150
+ * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1151
+ * @since v0.1.1
1152
+ */
1153
+ httpVersion: string;
1154
+ httpVersionMajor: number;
1155
+ httpVersionMinor: number;
1156
+ /**
1157
+ * The `message.complete` property will be `true` if a complete HTTP message has
1158
+ * been received and successfully parsed.
1159
+ *
1160
+ * This property is particularly useful as a means of determining if a client or
1161
+ * server fully transmitted a message before a connection was terminated:
1162
+ *
1163
+ * ```js
1164
+ * const req = http.request({
1165
+ * host: '127.0.0.1',
1166
+ * port: 8080,
1167
+ * method: 'POST',
1168
+ * }, (res) => {
1169
+ * res.resume();
1170
+ * res.on('end', () => {
1171
+ * if (!res.complete)
1172
+ * console.error(
1173
+ * 'The connection was terminated while the message was still being sent');
1174
+ * });
1175
+ * });
1176
+ * ```
1177
+ * @since v0.3.0
1178
+ */
1179
+ complete: boolean;
1180
+ /**
1181
+ * Alias for `message.socket`.
1182
+ * @since v0.1.90
1183
+ * @deprecated Since v16.0.0 - Use `socket`.
1184
+ */
1185
+ connection: Socket;
1186
+ /**
1187
+ * The `net.Socket` object associated with the connection.
1188
+ *
1189
+ * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the
1190
+ * client's authentication details.
1191
+ *
1192
+ * This property is guaranteed to be an instance of the `net.Socket` class,
1193
+ * a subclass of `stream.Duplex`, unless the user specified a socket
1194
+ * type other than `net.Socket` or internally nulled.
1195
+ * @since v0.3.0
1196
+ */
1197
+ socket: Socket;
1198
+ /**
1199
+ * The request/response headers object.
1200
+ *
1201
+ * Key-value pairs of header names and values. Header names are lower-cased.
1202
+ *
1203
+ * ```js
1204
+ * // Prints something like:
1205
+ * //
1206
+ * // { 'user-agent': 'curl/7.22.0',
1207
+ * // host: '127.0.0.1:8000',
1208
+ * // accept: '*' }
1209
+ * console.log(request.headers);
1210
+ * ```
1211
+ *
1212
+ * Duplicates in raw headers are handled in the following ways, depending on the
1213
+ * header name:
1214
+ *
1215
+ * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
1216
+ * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
1217
+ * To allow duplicate values of the headers listed above to be joined,
1218
+ * use the option `joinDuplicateHeaders` in {@link request} and {@link createServer}. See RFC 9110 Section 5.3 for more
1219
+ * information.
1220
+ * * `set-cookie` is always an array. Duplicates are added to the array.
1221
+ * * For duplicate `cookie` headers, the values are joined together with `; `.
1222
+ * * For all other headers, the values are joined together with `, `.
1223
+ * @since v0.1.5
1224
+ */
1225
+ headers: IncomingHttpHeaders;
1226
+ /**
1227
+ * Similar to `message.headers`, but there is no join logic and the values are
1228
+ * always arrays of strings, even for headers received just once.
1229
+ *
1230
+ * ```js
1231
+ * // Prints something like:
1232
+ * //
1233
+ * // { 'user-agent': ['curl/7.22.0'],
1234
+ * // host: ['127.0.0.1:8000'],
1235
+ * // accept: ['*'] }
1236
+ * console.log(request.headersDistinct);
1237
+ * ```
1238
+ * @since v18.3.0, v16.17.0
1239
+ */
1240
+ headersDistinct: NodeJS.Dict<string[]>;
1241
+ /**
1242
+ * The raw request/response headers list exactly as they were received.
1243
+ *
1244
+ * The keys and values are in the same list. It is _not_ a
1245
+ * list of tuples. So, the even-numbered offsets are key values, and the
1246
+ * odd-numbered offsets are the associated values.
1247
+ *
1248
+ * Header names are not lowercased, and duplicates are not merged.
1249
+ *
1250
+ * ```js
1251
+ * // Prints something like:
1252
+ * //
1253
+ * // [ 'user-agent',
1254
+ * // 'this is invalid because there can be only one',
1255
+ * // 'User-Agent',
1256
+ * // 'curl/7.22.0',
1257
+ * // 'Host',
1258
+ * // '127.0.0.1:8000',
1259
+ * // 'ACCEPT',
1260
+ * // '*' ]
1261
+ * console.log(request.rawHeaders);
1262
+ * ```
1263
+ * @since v0.11.6
1264
+ */
1265
+ rawHeaders: string[];
1266
+ /**
1267
+ * The request/response trailers object. Only populated at the `'end'` event.
1268
+ * @since v0.3.0
1269
+ */
1270
+ trailers: NodeJS.Dict<string>;
1271
+ /**
1272
+ * Similar to `message.trailers`, but there is no join logic and the values are
1273
+ * always arrays of strings, even for headers received just once.
1274
+ * Only populated at the `'end'` event.
1275
+ * @since v18.3.0, v16.17.0
1276
+ */
1277
+ trailersDistinct: NodeJS.Dict<string[]>;
1278
+ /**
1279
+ * The raw request/response trailer keys and values exactly as they were
1280
+ * received. Only populated at the `'end'` event.
1281
+ * @since v0.11.6
1282
+ */
1283
+ rawTrailers: string[];
1284
+ /**
1285
+ * Calls `message.socket.setTimeout(msecs, callback)`.
1286
+ * @since v0.5.9
1287
+ */
1288
+ setTimeout(msecs: number, callback?: () => void): this;
1289
+ /**
1290
+ * **Only valid for request obtained from {@link Server}.**
1291
+ *
1292
+ * The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`.
1293
+ * @since v0.1.1
1294
+ */
1295
+ method?: string | undefined;
1296
+ /**
1297
+ * **Only valid for request obtained from {@link Server}.**
1298
+ *
1299
+ * Request URL string. This contains only the URL that is present in the actual
1300
+ * HTTP request. Take the following request:
1301
+ *
1302
+ * ```http
1303
+ * GET /status?name=ryan HTTP/1.1
1304
+ * Accept: text/plain
1305
+ * ```
1306
+ *
1307
+ * To parse the URL into its parts:
1308
+ *
1309
+ * ```js
1310
+ * new URL(request.url, `http://${request.headers.host}`);
1311
+ * ```
1312
+ *
1313
+ * When `request.url` is `'/status?name=ryan'` and `request.headers.host` is`'localhost:3000'`:
1314
+ *
1315
+ * ```console
1316
+ * $ node
1317
+ * > new URL(request.url, `http://${request.headers.host}`)
1318
+ * URL {
1319
+ * href: 'http://localhost:3000/status?name=ryan',
1320
+ * origin: 'http://localhost:3000',
1321
+ * protocol: 'http:',
1322
+ * username: '',
1323
+ * password: '',
1324
+ * host: 'localhost:3000',
1325
+ * hostname: 'localhost',
1326
+ * port: '3000',
1327
+ * pathname: '/status',
1328
+ * search: '?name=ryan',
1329
+ * searchParams: URLSearchParams { 'name' => 'ryan' },
1330
+ * hash: ''
1331
+ * }
1332
+ * ```
1333
+ * @since v0.1.90
1334
+ */
1335
+ url?: string | undefined;
1336
+ /**
1337
+ * **Only valid for response obtained from {@link ClientRequest}.**
1338
+ *
1339
+ * The 3-digit HTTP response status code. E.G. `404`.
1340
+ * @since v0.1.1
1341
+ */
1342
+ statusCode?: number | undefined;
1343
+ /**
1344
+ * **Only valid for response obtained from {@link ClientRequest}.**
1345
+ *
1346
+ * The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`.
1347
+ * @since v0.11.10
1348
+ */
1349
+ statusMessage?: string | undefined;
1350
+ /**
1351
+ * Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed
1352
+ * as an argument to any listeners on the event.
1353
+ * @since v0.3.0
1354
+ */
1355
+ destroy(error?: Error): this;
1356
+ }
1357
+ interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1358
+ /**
1359
+ * Keep sockets around in a pool to be used by other requests in the future. Default = false
1360
+ */
1361
+ keepAlive?: boolean | undefined;
1362
+ /**
1363
+ * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
1364
+ * Only relevant if keepAlive is set to true.
1365
+ */
1366
+ keepAliveMsecs?: number | undefined;
1367
+ /**
1368
+ * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1369
+ */
1370
+ maxSockets?: number | undefined;
1371
+ /**
1372
+ * Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
1373
+ */
1374
+ maxTotalSockets?: number | undefined;
1375
+ /**
1376
+ * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
1377
+ */
1378
+ maxFreeSockets?: number | undefined;
1379
+ /**
1380
+ * Socket timeout in milliseconds. This will set the timeout after the socket is connected.
1381
+ */
1382
+ timeout?: number | undefined;
1383
+ /**
1384
+ * Scheduling strategy to apply when picking the next free socket to use.
1385
+ * @default `lifo`
1386
+ */
1387
+ scheduling?: "fifo" | "lifo" | undefined;
1388
+ }
1389
+ /**
1390
+ * An `Agent` is responsible for managing connection persistence
1391
+ * and reuse for HTTP clients. It maintains a queue of pending requests
1392
+ * for a given host and port, reusing a single socket connection for each
1393
+ * until the queue is empty, at which time the socket is either destroyed
1394
+ * or put into a pool where it is kept to be used again for requests to the
1395
+ * same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`.
1396
+ *
1397
+ * Pooled connections have TCP Keep-Alive enabled for them, but servers may
1398
+ * still close idle connections, in which case they will be removed from the
1399
+ * pool and a new connection will be made when a new HTTP request is made for
1400
+ * that host and port. Servers may also refuse to allow multiple requests
1401
+ * over the same connection, in which case the connection will have to be
1402
+ * remade for every request and cannot be pooled. The `Agent` will still make
1403
+ * the requests to that server, but each one will occur over a new connection.
1404
+ *
1405
+ * When a connection is closed by the client or the server, it is removed
1406
+ * from the pool. Any unused sockets in the pool will be unrefed so as not
1407
+ * to keep the Node.js process running when there are no outstanding requests.
1408
+ * (see `socket.unref()`).
1409
+ *
1410
+ * It is good practice, to `destroy()` an `Agent` instance when it is no
1411
+ * longer in use, because unused sockets consume OS resources.
1412
+ *
1413
+ * Sockets are removed from an agent when the socket emits either
1414
+ * a `'close'` event or an `'agentRemove'` event. When intending to keep one
1415
+ * HTTP request open for a long time without keeping it in the agent, something
1416
+ * like the following may be done:
1417
+ *
1418
+ * ```js
1419
+ * http.get(options, (res) => {
1420
+ * // Do stuff
1421
+ * }).on('socket', (socket) => {
1422
+ * socket.emit('agentRemove');
1423
+ * });
1424
+ * ```
1425
+ *
1426
+ * An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options
1427
+ * will be used
1428
+ * for the client connection.
1429
+ *
1430
+ * `agent:false`:
1431
+ *
1432
+ * ```js
1433
+ * http.get({
1434
+ * hostname: 'localhost',
1435
+ * port: 80,
1436
+ * path: '/',
1437
+ * agent: false, // Create a new agent just for this one request
1438
+ * }, (res) => {
1439
+ * // Do stuff with response
1440
+ * });
1441
+ * ```
1442
+ * @since v0.3.4
1443
+ */
1444
+ class Agent extends EventEmitter {
1445
+ /**
1446
+ * By default set to 256. For agents with `keepAlive` enabled, this
1447
+ * sets the maximum number of sockets that will be left open in the free
1448
+ * state.
1449
+ * @since v0.11.7
1450
+ */
1451
+ maxFreeSockets: number;
1452
+ /**
1453
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1454
+ * can have open per origin. Origin is the returned value of `agent.getName()`.
1455
+ * @since v0.3.6
1456
+ */
1457
+ maxSockets: number;
1458
+ /**
1459
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1460
+ * can have open. Unlike `maxSockets`, this parameter applies across all origins.
1461
+ * @since v14.5.0, v12.19.0
1462
+ */
1463
+ maxTotalSockets: number;
1464
+ /**
1465
+ * An object which contains arrays of sockets currently awaiting use by
1466
+ * the agent when `keepAlive` is enabled. Do not modify.
1467
+ *
1468
+ * Sockets in the `freeSockets` list will be automatically destroyed and
1469
+ * removed from the array on `'timeout'`.
1470
+ * @since v0.11.4
1471
+ */
1472
+ readonly freeSockets: NodeJS.ReadOnlyDict<Socket[]>;
1473
+ /**
1474
+ * An object which contains arrays of sockets currently in use by the
1475
+ * agent. Do not modify.
1476
+ * @since v0.3.6
1477
+ */
1478
+ readonly sockets: NodeJS.ReadOnlyDict<Socket[]>;
1479
+ /**
1480
+ * An object which contains queues of requests that have not yet been assigned to
1481
+ * sockets. Do not modify.
1482
+ * @since v0.5.9
1483
+ */
1484
+ readonly requests: NodeJS.ReadOnlyDict<IncomingMessage[]>;
1485
+ constructor(opts?: AgentOptions);
1486
+ /**
1487
+ * Destroy any sockets that are currently in use by the agent.
1488
+ *
1489
+ * It is usually not necessary to do this. However, if using an
1490
+ * agent with `keepAlive` enabled, then it is best to explicitly shut down
1491
+ * the agent when it is no longer needed. Otherwise,
1492
+ * sockets might stay open for quite a long time before the server
1493
+ * terminates them.
1494
+ * @since v0.11.4
1495
+ */
1496
+ destroy(): void;
1497
+ }
1498
+ const METHODS: string[];
1499
+ const STATUS_CODES: {
1500
+ [errorCode: number]: string | undefined;
1501
+ [errorCode: string]: string | undefined;
1502
+ };
1503
+ /**
1504
+ * Returns a new instance of {@link Server}.
1505
+ *
1506
+ * The `requestListener` is a function which is automatically
1507
+ * added to the `'request'` event.
1508
+ *
1509
+ * ```js
1510
+ * import http from 'node:http';
1511
+ *
1512
+ * // Create a local server to receive data from
1513
+ * const server = http.createServer((req, res) => {
1514
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1515
+ * res.end(JSON.stringify({
1516
+ * data: 'Hello World!',
1517
+ * }));
1518
+ * });
1519
+ *
1520
+ * server.listen(8000);
1521
+ * ```
1522
+ *
1523
+ * ```js
1524
+ * import http from 'node:http';
1525
+ *
1526
+ * // Create a local server to receive data from
1527
+ * const server = http.createServer();
1528
+ *
1529
+ * // Listen to the request event
1530
+ * server.on('request', (request, res) => {
1531
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1532
+ * res.end(JSON.stringify({
1533
+ * data: 'Hello World!',
1534
+ * }));
1535
+ * });
1536
+ *
1537
+ * server.listen(8000);
1538
+ * ```
1539
+ * @since v0.1.13
1540
+ */
1541
+ function createServer<
1542
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1543
+ Response extends typeof ServerResponse = typeof ServerResponse,
1544
+ >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1545
+ function createServer<
1546
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1547
+ Response extends typeof ServerResponse = typeof ServerResponse,
1548
+ >(
1549
+ options: ServerOptions<Request, Response>,
1550
+ requestListener?: RequestListener<Request, Response>,
1551
+ ): Server<Request, Response>;
1552
+ // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
1553
+ // create interface RequestOptions would make the naming more clear to developers
1554
+ interface RequestOptions extends ClientRequestArgs {}
1555
+ /**
1556
+ * `options` in `socket.connect()` are also supported.
1557
+ *
1558
+ * Node.js maintains several connections per server to make HTTP requests.
1559
+ * This function allows one to transparently issue requests.
1560
+ *
1561
+ * `url` can be a string or a `URL` object. If `url` is a
1562
+ * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
1563
+ *
1564
+ * If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence.
1565
+ *
1566
+ * The optional `callback` parameter will be added as a one-time listener for
1567
+ * the `'response'` event.
1568
+ *
1569
+ * `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to
1570
+ * upload a file with a POST request, then write to the `ClientRequest` object.
1571
+ *
1572
+ * ```js
1573
+ * import http from 'node:http';
1574
+ * import { Buffer } from 'node:buffer';
1575
+ *
1576
+ * const postData = JSON.stringify({
1577
+ * 'msg': 'Hello World!',
1578
+ * });
1579
+ *
1580
+ * const options = {
1581
+ * hostname: 'www.google.com',
1582
+ * port: 80,
1583
+ * path: '/upload',
1584
+ * method: 'POST',
1585
+ * headers: {
1586
+ * 'Content-Type': 'application/json',
1587
+ * 'Content-Length': Buffer.byteLength(postData),
1588
+ * },
1589
+ * };
1590
+ *
1591
+ * const req = http.request(options, (res) => {
1592
+ * console.log(`STATUS: ${res.statusCode}`);
1593
+ * console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
1594
+ * res.setEncoding('utf8');
1595
+ * res.on('data', (chunk) => {
1596
+ * console.log(`BODY: ${chunk}`);
1597
+ * });
1598
+ * res.on('end', () => {
1599
+ * console.log('No more data in response.');
1600
+ * });
1601
+ * });
1602
+ *
1603
+ * req.on('error', (e) => {
1604
+ * console.error(`problem with request: ${e.message}`);
1605
+ * });
1606
+ *
1607
+ * // Write data to request body
1608
+ * req.write(postData);
1609
+ * req.end();
1610
+ * ```
1611
+ *
1612
+ * In the example `req.end()` was called. With `http.request()` one
1613
+ * must always call `req.end()` to signify the end of the request -
1614
+ * even if there is no data being written to the request body.
1615
+ *
1616
+ * If any error is encountered during the request (be that with DNS resolution,
1617
+ * TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted
1618
+ * on the returned request object. As with all `'error'` events, if no listeners
1619
+ * are registered the error will be thrown.
1620
+ *
1621
+ * There are a few special headers that should be noted.
1622
+ *
1623
+ * * Sending a 'Connection: keep-alive' will notify Node.js that the connection to
1624
+ * the server should be persisted until the next request.
1625
+ * * Sending a 'Content-Length' header will disable the default chunked encoding.
1626
+ * * Sending an 'Expect' header will immediately send the request headers.
1627
+ * Usually, when sending 'Expect: 100-continue', both a timeout and a listener
1628
+ * for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more
1629
+ * information.
1630
+ * * Sending an Authorization header will override using the `auth` option
1631
+ * to compute basic authentication.
1632
+ *
1633
+ * Example using a `URL` as `options`:
1634
+ *
1635
+ * ```js
1636
+ * const options = new URL('http://abc:xyz@example.com');
1637
+ *
1638
+ * const req = http.request(options, (res) => {
1639
+ * // ...
1640
+ * });
1641
+ * ```
1642
+ *
1643
+ * In a successful request, the following events will be emitted in the following
1644
+ * order:
1645
+ *
1646
+ * * `'socket'`
1647
+ * * `'response'`
1648
+ * * `'data'` any number of times, on the `res` object
1649
+ * (`'data'` will not be emitted at all if the response body is empty, for
1650
+ * instance, in most redirects)
1651
+ * * `'end'` on the `res` object
1652
+ * * `'close'`
1653
+ *
1654
+ * In the case of a connection error, the following events will be emitted:
1655
+ *
1656
+ * * `'socket'`
1657
+ * * `'error'`
1658
+ * * `'close'`
1659
+ *
1660
+ * In the case of a premature connection close before the response is received,
1661
+ * the following events will be emitted in the following order:
1662
+ *
1663
+ * * `'socket'`
1664
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1665
+ * * `'close'`
1666
+ *
1667
+ * In the case of a premature connection close after the response is received,
1668
+ * the following events will be emitted in the following order:
1669
+ *
1670
+ * * `'socket'`
1671
+ * * `'response'`
1672
+ * * `'data'` any number of times, on the `res` object
1673
+ * * (connection closed here)
1674
+ * * `'aborted'` on the `res` object
1675
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`
1676
+ * * `'close'`
1677
+ * * `'close'` on the `res` object
1678
+ *
1679
+ * If `req.destroy()` is called before a socket is assigned, the following
1680
+ * events will be emitted in the following order:
1681
+ *
1682
+ * * (`req.destroy()` called here)
1683
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1684
+ * * `'close'`
1685
+ *
1686
+ * If `req.destroy()` is called before the connection succeeds, the following
1687
+ * events will be emitted in the following order:
1688
+ *
1689
+ * * `'socket'`
1690
+ * * (`req.destroy()` called here)
1691
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`, or the error with which `req.destroy()` was called
1692
+ * * `'close'`
1693
+ *
1694
+ * If `req.destroy()` is called after the response is received, the following
1695
+ * events will be emitted in the following order:
1696
+ *
1697
+ * * `'socket'`
1698
+ * * `'response'`
1699
+ * * `'data'` any number of times, on the `res` object
1700
+ * * (`req.destroy()` called here)
1701
+ * * `'aborted'` on the `res` object
1702
+ * * `'error'` on the `res` object with an error with message `'Error: aborted'`and code `'ECONNRESET'`, or the error with which `req.destroy()` was called
1703
+ * * `'close'`
1704
+ * * `'close'` on the `res` object
1705
+ *
1706
+ * If `req.abort()` is called before a socket is assigned, the following
1707
+ * events will be emitted in the following order:
1708
+ *
1709
+ * * (`req.abort()` called here)
1710
+ * * `'abort'`
1711
+ * * `'close'`
1712
+ *
1713
+ * If `req.abort()` is called before the connection succeeds, the following
1714
+ * events will be emitted in the following order:
1715
+ *
1716
+ * * `'socket'`
1717
+ * * (`req.abort()` called here)
1718
+ * * `'abort'`
1719
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1720
+ * * `'close'`
1721
+ *
1722
+ * If `req.abort()` is called after the response is received, the following
1723
+ * events will be emitted in the following order:
1724
+ *
1725
+ * * `'socket'`
1726
+ * * `'response'`
1727
+ * * `'data'` any number of times, on the `res` object
1728
+ * * (`req.abort()` called here)
1729
+ * * `'abort'`
1730
+ * * `'aborted'` on the `res` object
1731
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1732
+ * * `'close'`
1733
+ * * `'close'` on the `res` object
1734
+ *
1735
+ * Setting the `timeout` option or using the `setTimeout()` function will
1736
+ * not abort the request or do anything besides add a `'timeout'` event.
1737
+ *
1738
+ * Passing an `AbortSignal` and then calling `abort()` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1739
+ * request. Specifically, the `'error'` event will be emitted with an error with
1740
+ * the message `'AbortError: The operation was aborted'`, the code `'ABORT_ERR'`and the `cause`, if one was provided.
1741
+ * @since v0.3.6
1742
+ */
1743
+ function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1744
+ function request(
1745
+ url: string | URL,
1746
+ options: RequestOptions,
1747
+ callback?: (res: IncomingMessage) => void,
1748
+ ): ClientRequest;
1749
+ /**
1750
+ * Since most requests are GET requests without bodies, Node.js provides this
1751
+ * convenience method. The only difference between this method and {@link request} is that it sets the method to GET by default and calls `req.end()`automatically. The callback must take care to
1752
+ * consume the response
1753
+ * data for reasons stated in {@link ClientRequest} section.
1754
+ *
1755
+ * The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}.
1756
+ *
1757
+ * JSON fetching example:
1758
+ *
1759
+ * ```js
1760
+ * http.get('http://localhost:8000/', (res) => {
1761
+ * const { statusCode } = res;
1762
+ * const contentType = res.headers['content-type'];
1763
+ *
1764
+ * let error;
1765
+ * // Any 2xx status code signals a successful response but
1766
+ * // here we're only checking for 200.
1767
+ * if (statusCode !== 200) {
1768
+ * error = new Error('Request Failed.\n' +
1769
+ * `Status Code: ${statusCode}`);
1770
+ * } else if (!/^application\/json/.test(contentType)) {
1771
+ * error = new Error('Invalid content-type.\n' +
1772
+ * `Expected application/json but received ${contentType}`);
1773
+ * }
1774
+ * if (error) {
1775
+ * console.error(error.message);
1776
+ * // Consume response data to free up memory
1777
+ * res.resume();
1778
+ * return;
1779
+ * }
1780
+ *
1781
+ * res.setEncoding('utf8');
1782
+ * let rawData = '';
1783
+ * res.on('data', (chunk) => { rawData += chunk; });
1784
+ * res.on('end', () => {
1785
+ * try {
1786
+ * const parsedData = JSON.parse(rawData);
1787
+ * console.log(parsedData);
1788
+ * } catch (e) {
1789
+ * console.error(e.message);
1790
+ * }
1791
+ * });
1792
+ * }).on('error', (e) => {
1793
+ * console.error(`Got error: ${e.message}`);
1794
+ * });
1795
+ *
1796
+ * // Create a local server to receive data from
1797
+ * const server = http.createServer((req, res) => {
1798
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1799
+ * res.end(JSON.stringify({
1800
+ * data: 'Hello World!',
1801
+ * }));
1802
+ * });
1803
+ *
1804
+ * server.listen(8000);
1805
+ * ```
1806
+ * @since v0.3.6
1807
+ * @param options Accepts the same `options` as {@link request}, with the method set to GET by default.
1808
+ */
1809
+ function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1810
+ function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1811
+ /**
1812
+ * Performs the low-level validations on the provided `name` that are done when`res.setHeader(name, value)` is called.
1813
+ *
1814
+ * Passing illegal value as `name` will result in a `TypeError` being thrown,
1815
+ * identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1816
+ *
1817
+ * It is not necessary to use this method before passing headers to an HTTP request
1818
+ * or response. The HTTP module will automatically validate such headers.
1819
+ *
1820
+ * Example:
1821
+ *
1822
+ * ```js
1823
+ * import { validateHeaderName } from 'node:http';
1824
+ *
1825
+ * try {
1826
+ * validateHeaderName('');
1827
+ * } catch (err) {
1828
+ * console.error(err instanceof TypeError); // --> true
1829
+ * console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN'
1830
+ * console.error(err.message); // --> 'Header name must be a valid HTTP token [""]'
1831
+ * }
1832
+ * ```
1833
+ * @since v14.3.0
1834
+ * @param [label='Header name'] Label for error message.
1835
+ */
1836
+ function validateHeaderName(name: string): void;
1837
+ /**
1838
+ * Performs the low-level validations on the provided `value` that are done when`res.setHeader(name, value)` is called.
1839
+ *
1840
+ * Passing illegal value as `value` will result in a `TypeError` being thrown.
1841
+ *
1842
+ * * Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1843
+ * * Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1844
+ *
1845
+ * It is not necessary to use this method before passing headers to an HTTP request
1846
+ * or response. The HTTP module will automatically validate such headers.
1847
+ *
1848
+ * Examples:
1849
+ *
1850
+ * ```js
1851
+ * import { validateHeaderValue } from 'node:http';
1852
+ *
1853
+ * try {
1854
+ * validateHeaderValue('x-my-header', undefined);
1855
+ * } catch (err) {
1856
+ * console.error(err instanceof TypeError); // --> true
1857
+ * console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true
1858
+ * console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"'
1859
+ * }
1860
+ *
1861
+ * try {
1862
+ * validateHeaderValue('x-my-header', 'oʊmɪɡə');
1863
+ * } catch (err) {
1864
+ * console.error(err instanceof TypeError); // --> true
1865
+ * console.error(err.code === 'ERR_INVALID_CHAR'); // --> true
1866
+ * console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]'
1867
+ * }
1868
+ * ```
1869
+ * @since v14.3.0
1870
+ * @param name Header name
1871
+ * @param value Header value
1872
+ */
1873
+ function validateHeaderValue(name: string, value: string): void;
1874
+ /**
1875
+ * Set the maximum number of idle HTTP parsers.
1876
+ * @since v18.8.0, v16.18.0
1877
+ * @param [max=1000]
1878
+ */
1879
+ function setMaxIdleHTTPParsers(max: number): void;
1880
+ let globalAgent: Agent;
1881
+ /**
1882
+ * Read-only property specifying the maximum allowed size of HTTP headers in bytes.
1883
+ * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
1884
+ */
1885
+ const maxHeaderSize: number;
1886
+ }
1887
+ declare module "node:http" {
1888
+ export * from "http";
1889
+ }