mcpbrowser 0.2.2 → 0.2.3

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