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