CoolFace
Apppublic

Pinsave/counterstrike

sourceHugging Faceupdated 3mo agoView on Hugging Face
1likes
http2.d.ts2629 linesDownload Raw Back to node
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 * ```js6 * import http2 from 'node:http2';7 * ```8 * @since v8.4.09 * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/http2.js)10 */11declare 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    // Http2Stream35    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-type59        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.072         */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.078         */79        readonly bufferSize: number;80        /**81         * Set to `true` if the `Http2Stream` instance has been closed.82         * @since v9.4.083         */84        readonly closed: boolean;85        /**86         * Set to `true` if the `Http2Stream` instance has been destroyed and is no longer87         * usable.88         * @since v8.4.089         */90        readonly destroyed: boolean;91        /**92         * Set to `true` if the `END_STREAM` flag was set in the request or response93         * HEADERS frame received, indicating that no additional data should be received94         * and the readable side of the `Http2Stream` will be closed.95         * @since v10.11.096         */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.0101         */102        readonly id?: number | undefined;103        /**104         * Set to `true` if the `Http2Stream` instance has not yet been assigned a105         * numeric stream identifier.106         * @since v9.4.0107         */108        readonly pending: boolean;109        /**110         * Set to the `RST_STREAM` `error code` reported when the `Http2Stream` is111         * 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.0114         */115        readonly rstCode: number;116        /**117         * An object containing the outbound headers sent for this `Http2Stream`.118         * @since v9.5.0119         */120        readonly sentHeaders: OutgoingHttpHeaders;121        /**122         * An array of objects containing the outbound informational (additional) headers123         * sent for this `Http2Stream`.124         * @since v9.5.0125         */126        readonly sentInfoHeaders?: OutgoingHttpHeaders[] | undefined;127        /**128         * An object containing the outbound trailers sent for this `HttpStream`.129         * @since v9.5.0130         */131        readonly sentTrailers?: OutgoingHttpHeaders | undefined;132        /**133         * A reference to the `Http2Session` instance that owns this `Http2Stream`. The134         * value will be `undefined` after the `Http2Stream` instance is destroyed.135         * @since v8.4.0136         */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.0143         */144        readonly state: StreamState;145        /**146         * Closes the `Http2Stream` instance by sending an `RST_STREAM` frame to the147         * connected HTTP/2 peer.148         * @since v8.4.0149         * @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.0156         */157        priority(options: StreamPriorityOptions): void;158        /**159         * ```js160         * import http2 from '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 seconds166         * req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));167         * ```168         * @since v8.4.0169         */170        setTimeout(msecs: number, callback?: () => void): void;171        /**172         * Sends a trailing `HEADERS` frame to the connected HTTP/2 peer. This method173         * will cause the `Http2Stream` to be immediately closed and must only be174         * called after the `'wantTrailers'` event has been emitted. When sending a175         * request or sending a response, the `options.waitForTrailers` option must be set176         * in order to keep the `Http2Stream` open after the final `DATA` frame so that177         * trailers can be sent.178         *179         * ```js180         * import http2 from '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-header192         * fields (e.g. `':method'`, `':path'`, etc).193         * @since v10.0.0194         */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.0353         */354        readonly headersSent: boolean;355        /**356         * Read-only property mapped to the `SETTINGS_ENABLE_PUSH` flag of the remote357         * client's most recent `SETTINGS` frame. Will be `true` if the remote peer358         * accepts push streams, `false` otherwise. Settings are the same for every `Http2Stream` in the same `Http2Session`.359         * @since v8.4.0360         */361        readonly pushAllowed: boolean;362        /**363         * Sends an additional informational `HEADERS` frame to the connected HTTP/2 peer.364         * @since v8.4.0365         */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         * ```js371         * import http2 from '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. Pass385         * 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 permitted388         * and will throw an error.389         * @since v8.4.0390         * @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         * ```js403         * import http2 from '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'` event412         * will be emitted immediately after queuing the last chunk of payload data to be sent.413         * The `http2stream.sendTrailers()` method can then be used to send trailing header fields to the peer.414         *415         * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically416         * close when the final `DATA` frame is transmitted. User code must call either `http2stream.sendTrailers()` or `http2stream.close()` to close the `Http2Stream`.417         *418         * ```js419         * import http2 from '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.0430         */431        respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;432        /**433         * Initiates a response whose data is read from the given file descriptor. No434         * validation is performed on the given file descriptor. If an error occurs while435         * attempting to read data using the file descriptor, the `Http2Stream` will be436         * closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.437         *438         * When used, the `Http2Stream` object's `Duplex` interface will be closed439         * automatically.440         *441         * ```js442         * import http2 from 'node:http2';443         * import fs from '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 code461         * an opportunity to set additional content headers based on the `fs.Stat` details462         * of the given fd. If the `statCheck` function is provided, the `http2stream.respondWithFD()` method will463         * perform an `fs.fstat()` call to collect details on the provided file descriptor.464         *465         * The `offset` and `length` options may be used to limit the response to a466         * specific range subset. This can be used, for instance, to support HTTP Range467         * 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 streams472         * is not supported and may result in data loss. Re-using a file descriptor473         * after a stream has finished is supported.474         *475         * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event476         * will be emitted immediately after queuing the last chunk of payload data to be477         * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing478         * header fields to the peer.479         *480         * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically481         * close when the final `DATA` frame is transmitted. User code _must_ call either `http2stream.sendTrailers()`482         * or `http2stream.close()` to close the `Http2Stream`.483         *484         * ```js485         * import http2 from 'node:http2';486         * import fs from 'node:fs';487         *488         * const server = http2.createServer();489         * server.on('stream', (stream) => {490         *   const fd = fs.openSync('/some/file', 'r');491         *492         *   const stat = fs.fstatSync(fd);493         *   const headers = {494         *     'content-length': stat.size,495         *     'last-modified': stat.mtime.toUTCString(),496         *     'content-type': 'text/plain; charset=utf-8',497         *   };498         *   stream.respondWithFD(fd, headers, { waitForTrailers: true });499         *   stream.on('wantTrailers', () => {500         *     stream.sendTrailers({ ABC: 'some value to send' });501         *   });502         *503         *   stream.on('close', () => fs.closeSync(fd));504         * });505         * ```506         * @since v8.4.0507         * @param fd A readable file descriptor.508         */509        respondWithFD(510            fd: number | fs.promises.FileHandle,511            headers?: OutgoingHttpHeaders,512            options?: ServerStreamFileResponseOptions,513        ): void;514        /**515         * Sends a regular file as the response. The `path` must specify a regular file516         * or an `'error'` event will be emitted on the `Http2Stream` object.517         *518         * When used, the `Http2Stream` object's `Duplex` interface will be closed519         * automatically.520         *521         * The optional `options.statCheck` function may be specified to give user code522         * an opportunity to set additional content headers based on the `fs.Stat` details523         * of the given file:524         *525         * If an error occurs while attempting to read the file data, the `Http2Stream` will be closed using an526         * `RST_STREAM` frame using the standard `INTERNAL_ERROR` code.527         * If the `onError` callback is defined, then it will be called. Otherwise, the stream will be destroyed.528         *529         * Example using a file path:530         *531         * ```js532         * import http2 from 'node:http2';533         * const server = http2.createServer();534         * server.on('stream', (stream) => {535         *   function statCheck(stat, headers) {536         *     headers['last-modified'] = stat.mtime.toUTCString();537         *   }538         *539         *   function onError(err) {540         *     // stream.respond() can throw if the stream has been destroyed by541         *     // the other side.542         *     try {543         *       if (err.code === 'ENOENT') {544         *         stream.respond({ ':status': 404 });545         *       } else {546         *         stream.respond({ ':status': 500 });547         *       }548         *     } catch (err) {549         *       // Perform actual error handling.550         *       console.error(err);551         *     }552         *     stream.end();553         *   }554         *555         *   stream.respondWithFile('/some/file',556         *                          { 'content-type': 'text/plain; charset=utf-8' },557         *                          { statCheck, onError });558         * });559         * ```560         *561         * The `options.statCheck` function may also be used to cancel the send operation562         * by returning `false`. For instance, a conditional request may check the stat563         * results to determine if the file has been modified to return an appropriate `304` response:564         *565         * ```js566         * import http2 from 'node:http2';567         * const server = http2.createServer();568         * server.on('stream', (stream) => {569         *   function statCheck(stat, headers) {570         *     // Check the stat here...571         *     stream.respond({ ':status': 304 });572         *     return false; // Cancel the send operation573         *   }574         *   stream.respondWithFile('/some/file',575         *                          { 'content-type': 'text/plain; charset=utf-8' },576         *                          { statCheck });577         * });578         * ```579         *580         * The `content-length` header field will be automatically set.581         *582         * The `offset` and `length` options may be used to limit the response to a583         * specific range subset. This can be used, for instance, to support HTTP Range584         * requests.585         *586         * The `options.onError` function may also be used to handle all the errors587         * that could happen before the delivery of the file is initiated. The588         * default behavior is to destroy the stream.589         *590         * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event591         * will be emitted immediately after queuing the last chunk of payload data to be592         * sent. The `http2stream.sendTrailers()` method can then be used to sent trailing593         * header fields to the peer.594         *595         * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically596         * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.597         *598         * ```js599         * import http2 from 'node:http2';600         * const server = http2.createServer();601         * server.on('stream', (stream) => {602         *   stream.respondWithFile('/some/file',603         *                          { 'content-type': 'text/plain; charset=utf-8' },604         *                          { waitForTrailers: true });605         *   stream.on('wantTrailers', () => {606         *     stream.sendTrailers({ ABC: 'some value to send' });607         *   });608         * });609         * ```610         * @since v8.4.0611         */612        respondWithFile(613            path: string,614            headers?: OutgoingHttpHeaders,615            options?: ServerStreamFileResponseOptionsWithError,616        ): void;617    }618    // Http2Session619    export interface Settings {620        headerTableSize?: number | undefined;621        enablePush?: boolean | undefined;622        initialWindowSize?: number | undefined;623        maxFrameSize?: number | undefined;624        maxConcurrentStreams?: number | undefined;625        maxHeaderListSize?: number | undefined;626        enableConnectProtocol?: boolean | undefined;627    }628    export interface ClientSessionRequestOptions {629        endStream?: boolean | undefined;630        exclusive?: boolean | undefined;631        parent?: number | undefined;632        weight?: number | undefined;633        waitForTrailers?: boolean | undefined;634        signal?: AbortSignal | undefined;635    }636    export interface SessionState {637        effectiveLocalWindowSize?: number | undefined;638        effectiveRecvDataLength?: number | undefined;639        nextStreamID?: number | undefined;640        localWindowSize?: number | undefined;641        lastProcStreamID?: number | undefined;642        remoteWindowSize?: number | undefined;643        outboundQueueSize?: number | undefined;644        deflateDynamicTableSize?: number | undefined;645        inflateDynamicTableSize?: number | undefined;646    }647    export interface Http2Session extends EventEmitter {648        /**649         * Value will be `undefined` if the `Http2Session` is not yet connected to a650         * socket, `h2c` if the `Http2Session` is not connected to a `TLSSocket`, or651         * will return the value of the connected `TLSSocket`'s own `alpnProtocol` property.652         * @since v9.4.0653         */654        readonly alpnProtocol?: string | undefined;655        /**656         * Will be `true` if this `Http2Session` instance has been closed, otherwise `false`.657         * @since v9.4.0658         */659        readonly closed: boolean;660        /**661         * Will be `true` if this `Http2Session` instance is still connecting, will be set662         * to `false` before emitting `connect` event and/or calling the `http2.connect` callback.663         * @since v10.0.0664         */665        readonly connecting: boolean;666        /**667         * Will be `true` if this `Http2Session` instance has been destroyed and must no668         * longer be used, otherwise `false`.669         * @since v8.4.0670         */671        readonly destroyed: boolean;672        /**673         * Value is `undefined` if the `Http2Session` session socket has not yet been674         * connected, `true` if the `Http2Session` is connected with a `TLSSocket`,675         * and `false` if the `Http2Session` is connected to any other kind of socket676         * or stream.677         * @since v9.4.0678         */679        readonly encrypted?: boolean | undefined;680        /**681         * A prototype-less object describing the current local settings of this `Http2Session`.682         * The local settings are local to _this_`Http2Session` instance.683         * @since v8.4.0684         */685        readonly localSettings: Settings;686        /**687         * If the `Http2Session` is connected to a `TLSSocket`, the `originSet` property688         * will return an `Array` of origins for which the `Http2Session` may be689         * considered authoritative.690         *691         * The `originSet` property is only available when using a secure TLS connection.692         * @since v9.4.0693         */694        readonly originSet?: string[] | undefined;695        /**696         * Indicates whether the `Http2Session` is currently waiting for acknowledgment of697         * a sent `SETTINGS` frame. Will be `true` after calling the `http2session.settings()` method.698         * Will be `false` once all sent `SETTINGS` frames have been acknowledged.699         * @since v8.4.0700         */701        readonly pendingSettingsAck: boolean;702        /**703         * A prototype-less object describing the current remote settings of this`Http2Session`.704         * The remote settings are set by the _connected_ HTTP/2 peer.705         * @since v8.4.0706         */707        readonly remoteSettings: Settings;708        /**709         * Returns a `Proxy` object that acts as a `net.Socket` (or `tls.TLSSocket`) but710         * limits available methods to ones safe to use with HTTP/2.711         *712         * `destroy`, `emit`, `end`, `pause`, `read`, `resume`, and `write` will throw713         * an error with code `ERR_HTTP2_NO_SOCKET_MANIPULATION`. See `Http2Session and Sockets` for more information.714         *715         * `setTimeout` method will be called on this `Http2Session`.716         *717         * All other interactions will be routed directly to the socket.718         * @since v8.4.0719         */720        readonly socket: net.Socket | tls.TLSSocket;721        /**722         * Provides miscellaneous information about the current state of the`Http2Session`.723         *724         * An object describing the current status of this `Http2Session`.725         * @since v8.4.0726         */727        readonly state: SessionState;728        /**729         * The `http2session.type` will be equal to `http2.constants.NGHTTP2_SESSION_SERVER` if this `Http2Session` instance is a730         * server, and `http2.constants.NGHTTP2_SESSION_CLIENT` if the instance is a731         * client.732         * @since v8.4.0733         */734        readonly type: number;735        /**736         * Gracefully closes the `Http2Session`, allowing any existing streams to737         * complete on their own and preventing new `Http2Stream` instances from being738         * created. Once closed, `http2session.destroy()`_might_ be called if there739         * are no open `Http2Stream` instances.740         *741         * If specified, the `callback` function is registered as a handler for the`'close'` event.742         * @since v9.4.0743         */744        close(callback?: () => void): void;745        /**746         * Immediately terminates the `Http2Session` and the associated `net.Socket` or `tls.TLSSocket`.747         *748         * 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.749         *750         * If there are any remaining open `Http2Streams` associated with the `Http2Session`, those will also be destroyed.751         * @since v8.4.0752         * @param error An `Error` object if the `Http2Session` is being destroyed due to an error.753         * @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`.754         */755        destroy(error?: Error, code?: number): void;756        /**757         * Transmits a `GOAWAY` frame to the connected peer _without_ shutting down the`Http2Session`.758         * @since v9.4.0759         * @param code An HTTP/2 error code760         * @param lastStreamID The numeric ID of the last processed `Http2Stream`761         * @param opaqueData A `TypedArray` or `DataView` instance containing additional data to be carried within the `GOAWAY` frame.762         */763        goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;764        /**765         * Sends a `PING` frame to the connected HTTP/2 peer. A `callback` function must766         * be provided. The method will return `true` if the `PING` was sent, `false` otherwise.767         *768         * The maximum number of outstanding (unacknowledged) pings is determined by the `maxOutstandingPings` configuration option. The default maximum is 10.769         *770         * If provided, the `payload` must be a `Buffer`, `TypedArray`, or `DataView` containing 8 bytes of data that will be transmitted with the `PING` and771         * returned with the ping acknowledgment.772         *773         * The callback will be invoked with three arguments: an error argument that will774         * be `null` if the `PING` was successfully acknowledged, a `duration` argument775         * that reports the number of milliseconds elapsed since the ping was sent and the776         * acknowledgment was received, and a `Buffer` containing the 8-byte `PING` payload.777         *778         * ```js779         * session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {780         *   if (!err) {781         *     console.log(`Ping acknowledged in ${duration} milliseconds`);782         *     console.log(`With payload '${payload.toString()}'`);783         *   }784         * });785         * ```786         *787         * If the `payload` argument is not specified, the default payload will be the788         * 64-bit timestamp (little endian) marking the start of the `PING` duration.789         * @since v8.9.3790         * @param payload Optional ping payload.791         */792        ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;793        ping(794            payload: NodeJS.ArrayBufferView,795            callback: (err: Error | null, duration: number, payload: Buffer) => void,796        ): boolean;797        /**798         * Calls `ref()` on this `Http2Session` instance's underlying `net.Socket`.799         * @since v9.4.0800         */801        ref(): void;802        /**803         * Sets the local endpoint's window size.804         * The `windowSize` is the total window size to set, not805         * the delta.806         *807         * ```js808         * import http2 from 'node:http2';809         *810         * const server = http2.createServer();811         * const expectedWindowSize = 2 ** 20;812         * server.on('connect', (session) => {813         *814         *   // Set local window size to be 2 ** 20815         *   session.setLocalWindowSize(expectedWindowSize);816         * });817         * ```818         * @since v15.3.0, v14.18.0819         */820        setLocalWindowSize(windowSize: number): void;821        /**822         * Used to set a callback function that is called when there is no activity on823         * the `Http2Session` after `msecs` milliseconds. The given `callback` is824         * registered as a listener on the `'timeout'` event.825         * @since v8.4.0826         */827        setTimeout(msecs: number, callback?: () => void): void;828        /**829         * Updates the current local settings for this `Http2Session` and sends a new `SETTINGS` frame to the connected HTTP/2 peer.830         *831         * Once called, the `http2session.pendingSettingsAck` property will be `true` while the session is waiting for the remote peer to acknowledge the new832         * settings.833         *834         * The new settings will not become effective until the `SETTINGS` acknowledgment835         * is received and the `'localSettings'` event is emitted. It is possible to send836         * multiple `SETTINGS` frames while acknowledgment is still pending.837         * @since v8.4.0838         * @param callback Callback that is called once the session is connected or right away if the session is already connected.839         */840        settings(841            settings: Settings,842            callback?: (err: Error | null, settings: Settings, duration: number) => void,843        ): void;844        /**845         * Calls `unref()` on this `Http2Session`instance's underlying `net.Socket`.846         * @since v9.4.0847         */848        unref(): void;849        addListener(event: "close", listener: () => void): this;850        addListener(event: "error", listener: (err: Error) => void): this;851        addListener(852            event: "frameError",853            listener: (frameType: number, errorCode: number, streamID: number) => void,854        ): this;855        addListener(856            event: "goaway",857            listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,858        ): this;859        addListener(event: "localSettings", listener: (settings: Settings) => void): this;860        addListener(event: "ping", listener: () => void): this;861        addListener(event: "remoteSettings", listener: (settings: Settings) => void): this;862        addListener(event: "timeout", listener: () => void): this;863        addListener(event: string | symbol, listener: (...args: any[]) => void): this;864        emit(event: "close"): boolean;865        emit(event: "error", err: Error): boolean;866        emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean;867        emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData?: Buffer): boolean;868        emit(event: "localSettings", settings: Settings): boolean;869        emit(event: "ping"): boolean;870        emit(event: "remoteSettings", settings: Settings): boolean;871        emit(event: "timeout"): boolean;872        emit(event: string | symbol, ...args: any[]): boolean;873        on(event: "close", listener: () => void): this;874        on(event: "error", listener: (err: Error) => void): this;875        on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;876        on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this;877        on(event: "localSettings", listener: (settings: Settings) => void): this;878        on(event: "ping", listener: () => void): this;879        on(event: "remoteSettings", listener: (settings: Settings) => void): this;880        on(event: "timeout", listener: () => void): this;881        on(event: string | symbol, listener: (...args: any[]) => void): this;882        once(event: "close", listener: () => void): this;883        once(event: "error", listener: (err: Error) => void): this;884        once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;885        once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void): this;886        once(event: "localSettings", listener: (settings: Settings) => void): this;887        once(event: "ping", listener: () => void): this;888        once(event: "remoteSettings", listener: (settings: Settings) => void): this;889        once(event: "timeout", listener: () => void): this;890        once(event: string | symbol, listener: (...args: any[]) => void): this;891        prependListener(event: "close", listener: () => void): this;892        prependListener(event: "error", listener: (err: Error) => void): this;893        prependListener(894            event: "frameError",895            listener: (frameType: number, errorCode: number, streamID: number) => void,896        ): this;897        prependListener(898            event: "goaway",899            listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,900        ): this;901        prependListener(event: "localSettings", listener: (settings: Settings) => void): this;902        prependListener(event: "ping", listener: () => void): this;903        prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this;904        prependListener(event: "timeout", listener: () => void): this;905        prependListener(event: string | symbol, listener: (...args: any[]) => void): this;906        prependOnceListener(event: "close", listener: () => void): this;907        prependOnceListener(event: "error", listener: (err: Error) => void): this;908        prependOnceListener(909            event: "frameError",910            listener: (frameType: number, errorCode: number, streamID: number) => void,911        ): this;912        prependOnceListener(913            event: "goaway",914            listener: (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => void,915        ): this;916        prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;917        prependOnceListener(event: "ping", listener: () => void): this;918        prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this;919        prependOnceListener(event: "timeout", listener: () => void): this;920        prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;921    }922    export interface ClientHttp2Session extends Http2Session {923        /**924         * For HTTP/2 Client `Http2Session` instances only, the `http2session.request()` creates and returns an `Http2Stream` instance that can be used to send an925         * HTTP/2 request to the connected server.926         *927         * When a `ClientHttp2Session` is first created, the socket may not yet be928         * connected. if `clienthttp2session.request()` is called during this time, the929         * actual request will be deferred until the socket is ready to go.930         * If the `session` is closed before the actual request be executed, an `ERR_HTTP2_GOAWAY_SESSION` is thrown.931         *932         * This method is only available if `http2session.type` is equal to `http2.constants.NGHTTP2_SESSION_CLIENT`.933         *934         * ```js935         * import http2 from 'node:http2';936         * const clientSession = http2.connect('https://localhost:1234');937         * const {938         *   HTTP2_HEADER_PATH,939         *   HTTP2_HEADER_STATUS,940         * } = http2.constants;941         *942         * const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });943         * req.on('response', (headers) => {944         *   console.log(headers[HTTP2_HEADER_STATUS]);945         *   req.on('data', (chunk) => { // ..  });946         *   req.on('end', () => { // ..  });947         * });948         * ```949         *950         * When the `options.waitForTrailers` option is set, the `'wantTrailers'` event951         * is emitted immediately after queuing the last chunk of payload data to be sent.952         * The `http2stream.sendTrailers()` method can then be called to send trailing953         * headers to the peer.954         *955         * When `options.waitForTrailers` is set, the `Http2Stream` will not automatically956         * close when the final `DATA` frame is transmitted. User code must call either`http2stream.sendTrailers()` or `http2stream.close()` to close the`Http2Stream`.957         *958         * When `options.signal` is set with an `AbortSignal` and then `abort` on the959         * corresponding `AbortController` is called, the request will emit an `'error'`event with an `AbortError` error.960         *961         * The `:method` and `:path` pseudo-headers are not specified within `headers`,962         * they respectively default to:963         *964         * * `:method` \= `'GET'`965         * * `:path` \= `/`966         * @since v8.4.0967         */968        request(969            headers?: OutgoingHttpHeaders | readonly string[],970            options?: ClientSessionRequestOptions,971        ): ClientHttp2Stream;972        addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;973        addListener(event: "origin", listener: (origins: string[]) => void): this;974        addListener(975            event: "connect",976            listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,977        ): this;978        addListener(979            event: "stream",980            listener: (981                stream: ClientHttp2Stream,982                headers: IncomingHttpHeaders & IncomingHttpStatusHeader,983                flags: number,984            ) => void,985        ): this;986        addListener(event: string | symbol, listener: (...args: any[]) => void): this;987        emit(event: "altsvc", alt: string, origin: string, stream: number): boolean;988        emit(event: "origin", origins: readonly string[]): boolean;989        emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;990        emit(991            event: "stream",992            stream: ClientHttp2Stream,993            headers: IncomingHttpHeaders & IncomingHttpStatusHeader,994            flags: number,995        ): boolean;996        emit(event: string | symbol, ...args: any[]): boolean;997        on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;998        on(event: "origin", listener: (origins: string[]) => void): this;999        on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;1000        on(1001            event: "stream",1002            listener: (1003                stream: ClientHttp2Stream,1004                headers: IncomingHttpHeaders & IncomingHttpStatusHeader,1005                flags: number,1006            ) => void,1007        ): this;1008        on(event: string | symbol, listener: (...args: any[]) => void): this;1009        once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;1010        once(event: "origin", listener: (origins: string[]) => void): this;1011        once(1012            event: "connect",1013            listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,1014        ): this;1015        once(1016            event: "stream",1017            listener: (1018                stream: ClientHttp2Stream,1019                headers: IncomingHttpHeaders & IncomingHttpStatusHeader,1020                flags: number,1021            ) => void,1022        ): this;1023        once(event: string | symbol, listener: (...args: any[]) => void): this;1024        prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;1025        prependListener(event: "origin", listener: (origins: string[]) => void): this;1026        prependListener(1027            event: "connect",1028            listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,1029        ): this;1030        prependListener(1031            event: "stream",1032            listener: (1033                stream: ClientHttp2Stream,1034                headers: IncomingHttpHeaders & IncomingHttpStatusHeader,1035                flags: number,1036            ) => void,1037        ): this;1038        prependListener(event: string | symbol, listener: (...args: any[]) => void): this;1039        prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;1040        prependOnceListener(event: "origin", listener: (origins: string[]) => void): this;1041        prependOnceListener(1042            event: "connect",1043            listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void,1044        ): this;1045        prependOnceListener(1046            event: "stream",1047            listener: (1048                stream: ClientHttp2Stream,1049                headers: IncomingHttpHeaders & IncomingHttpStatusHeader,1050                flags: number,1051            ) => void,1052        ): this;1053        prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;1054    }1055    export interface AlternativeServiceOptions {1056        origin: number | string | url.URL;1057    }1058    export interface ServerHttp2Session<1059        Http1Request extends typeof IncomingMessage = typeof IncomingMessage,1060        Http1Response extends typeof ServerResponse<InstanceType<Http1Request>> = typeof ServerResponse,1061        Http2Request extends typeof Http2ServerRequest = typeof Http2ServerRequest,1062        Http2Response extends typeof Http2ServerResponse<InstanceType<Http2Request>> = typeof Http2ServerResponse,1063    > extends Http2Session {1064        readonly server:1065            | Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>1066            | Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>;1067        /**1068         * Submits an `ALTSVC` frame (as defined by [RFC 7838](https://tools.ietf.org/html/rfc7838)) to the connected client.1069         *1070         * ```js1071         * import http2 from 'node:http2';1072         *1073         * const server = http2.createServer();1074         * server.on('session', (session) => {1075         *   // Set altsvc for origin https://example.org:801076         *   session.altsvc('h2=":8000"', 'https://example.org:80');1077         * });1078         *1079         * server.on('stream', (stream) => {1080         *   // Set altsvc for a specific stream1081         *   stream.session.altsvc('h2=":8000"', stream.id);1082         * });1083         * ```1084         *1085         * Sending an `ALTSVC` frame with a specific stream ID indicates that the alternate1086         * service is associated with the origin of the given `Http2Stream`.1087         *1088         * The `alt` and origin string _must_ contain only ASCII bytes and are1089         * strictly interpreted as a sequence of ASCII bytes. The special value `'clear'`may be passed to clear any previously set alternative service for a given1090         * domain.1091         *1092         * When a string is passed for the `originOrStream` argument, it will be parsed as1093         * a URL and the origin will be derived. For instance, the origin for the1094         * HTTP URL `'https://example.org/foo/bar'` is the ASCII string`'https://example.org'`. An error will be thrown if either the given string1095         * cannot be parsed as a URL or if a valid origin cannot be derived.1096         *1097         * 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 be1098         * used. The value of the `origin` property _must_ be a properly serialized1099         * ASCII origin.1100         * @since v9.4.01101         * @param alt A description of the alternative service configuration as defined by `RFC 7838`.1102         * @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 the1103         * `http2stream.id` property.1104         */1105        altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void;1106        /**1107         * Submits an `ORIGIN` frame (as defined by [RFC 8336](https://tools.ietf.org/html/rfc8336)) to the connected client1108         * to advertise the set of origins for which the server is capable of providing1109         * authoritative responses.1110         *1111         * ```js1112         * import http2 from 'node:http2';1113         * const options = getSecureOptionsSomehow();1114         * const server = http2.createSecureServer(options);1115         * server.on('stream', (stream) => {1116         *   stream.respond();1117         *   stream.end('ok');1118         * });1119         * server.on('session', (session) => {1120         *   session.origin('https://example.com', 'https://example.org');1121         * });1122         * ```1123         *1124         * When a string is passed as an `origin`, it will be parsed as a URL and the1125         * 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 given1126         * string1127         * cannot be parsed as a URL or if a valid origin cannot be derived.1128         *1129         * A `URL` object, or any object with an `origin` property, may be passed as1130         * an `origin`, in which case the value of the `origin` property will be1131         * used. The value of the `origin` property _must_ be a properly serialized1132         * ASCII origin.1133         *1134         * Alternatively, the `origins` option may be used when creating a new HTTP/21135         * server using the `http2.createSecureServer()` method:1136         *1137         * ```js1138         * import http2 from 'node:http2';1139         * const options = getSecureOptionsSomehow();1140         * options.origins = ['https://example.com', 'https://example.org'];1141         * const server = http2.createSecureServer(options);1142         * server.on('stream', (stream) => {1143         *   stream.respond();1144         *   stream.end('ok');1145         * });1146         * ```1147         * @since v10.12.01148         * @param origins One or more URL Strings passed as separate arguments.1149         */1150        origin(1151            ...origins: Array<1152                | string1153                | url.URL1154                | {1155                    origin: string;1156                }1157            >1158        ): void;1159        addListener(1160            event: "connect",1161            listener: (1162                session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,1163                socket: net.Socket | tls.TLSSocket,1164            ) => void,1165        ): this;1166        addListener(1167            event: "stream",1168            listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,1169        ): this;1170        addListener(event: string | symbol, listener: (...args: any[]) => void): this;1171        emit(1172            event: "connect",1173            session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,1174            socket: net.Socket | tls.TLSSocket,1175        ): boolean;1176        emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;1177        emit(event: string | symbol, ...args: any[]): boolean;1178        on(1179            event: "connect",1180            listener: (1181                session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,1182                socket: net.Socket | tls.TLSSocket,1183            ) => void,1184        ): this;1185        on(1186            event: "stream",1187            listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,1188        ): this;1189        on(event: string | symbol, listener: (...args: any[]) => void): this;1190        once(1191            event: "connect",1192            listener: (1193                session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,1194                socket: net.Socket | tls.TLSSocket,1195            ) => void,1196        ): this;1197        once(1198            event: "stream",1199            listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void,1200        ): this;

Showing the first 1,200 of 2629 lines. Download the file for the rest.