rahad-all-downloader 2.1.16 → 2.1.17

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