The following methods are non-functional stubs:
- aborted
- bufferSize
- endAfterHeaders
- id
- pending
- priority
- rstCode
- sentHeaders
- sentInfoHeaders
- sentTrailers
- state
Properties Jump to heading
Jump to headingaborted: booleanSet to true if the Http2Stream instance was aborted abnormally. When set,
the 'aborted' event will have been emitted.
Jump to headingbufferSize: numberThis property shows the number of characters currently buffered to be written.
See net.Socket.bufferSize for details.
Jump to headingclosed: booleanSet to true if the Http2Stream instance has been closed.
Jump to headingdestroyed: booleanSet to true if the Http2Stream instance has been destroyed and is no longer
usable.
Jump to headingendAfterHeaders: booleanSet to true if the END_STREAM flag was set in the request or response
HEADERS frame received, indicating that no additional data should be received
and the readable side of the Http2Stream will be closed.
Jump to headingid: number | undefinedThe numeric stream identifier of this Http2Stream instance. Set to undefined if the stream identifier has not yet been assigned.
Jump to headingpending: booleanSet to true if the Http2Stream instance has not yet been assigned a
numeric stream identifier.
Jump to headingrstCode: numberSet to the RST_STREAM error code reported when the Http2Stream is
destroyed after either receiving an RST_STREAM frame from the connected peer,
calling http2stream.close(), or http2stream.destroy(). Will be undefined if the Http2Stream has not been closed.
An object containing the outbound headers sent for this Http2Stream.
Jump to headingsentInfoHeaders: OutgoingHttpHeaders[] | undefinedAn array of objects containing the outbound informational (additional) headers
sent for this Http2Stream.
Jump to headingsentTrailers: OutgoingHttpHeaders | undefinedAn object containing the outbound trailers sent for this HttpStream.
Jump to headingsession: Http2Session | undefinedA reference to the Http2Session instance that owns this Http2Stream. The
value will be undefined after the Http2Stream instance is destroyed.
Jump to headingstate: StreamStateProvides miscellaneous information about the current state of the Http2Stream.
A current state of this Http2Stream.
Methods Jump to heading
Jump to headingclose(code?: number,callback?: () => void,): voidCloses the Http2Stream instance by sending an RST_STREAM frame to the
connected HTTP/2 peer.
Jump to headingpriority(options: StreamPriorityOptions): voidUpdates the priority for this Http2Stream instance.
Jump to headingsetTimeout(msecs: number,callback?: () => void,): voidimport http2 from 'node:http2';
const client = http2.connect('http://example.org:8000');
const { NGHTTP2_CANCEL } = http2.constants;
const req = client.request({ ':path': '/' });
// Cancel the stream if there's no activity after 5 seconds
req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));
Jump to headingsendTrailers(headers: OutgoingHttpHeaders): voidSends a trailing HEADERS frame to the connected HTTP/2 peer. This method
will cause the Http2Stream to be immediately closed and must only be
called after the 'wantTrailers' event has been emitted. When sending a
request or sending a response, the options.waitForTrailers option must be set
in order to keep the Http2Stream open after the final DATA frame so that
trailers can be sent.
import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond(undefined, { waitForTrailers: true });
stream.on('wantTrailers', () => {
stream.sendTrailers({ xyz: 'abc' });
});
stream.end('Hello World');
});
The HTTP/1 specification forbids trailers from containing HTTP/2 pseudo-header
fields (e.g. ':method', ':path', etc).
Jump to headingaddListener(event: "aborted",listener: () => void,): thisJump to headingaddListener(event: "close",listener: () => void,): thisJump to headingaddListener(event: "data",listener: (chunk: Buffer | string) => void,): thisJump to headingaddListener(event: "drain",listener: () => void,): thisJump to headingaddListener(event: "end",listener: () => void,): thisJump to headingaddListener(event: "error",listener: (err: Error) => void,): thisJump to headingaddListener(event: "finish",listener: () => void,): thisJump to headingaddListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): thisJump to headingaddListener(event: "pipe",listener: (src: stream.Readable) => void,): thisJump to headingaddListener(event: "unpipe",listener: (src: stream.Readable) => void,): thisJump to headingaddListener(event: "streamClosed",listener: (code: number) => void,): thisJump to headingaddListener(event: "timeout",listener: () => void,): thisJump to headingaddListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): thisJump to headingaddListener(event: "wantTrailers",listener: () => void,): thisJump to headingaddListener(event: string | symbol,listener: (...args: any[]) => void,): thisJump to headingemit(event: "aborted"): booleanJump to headingemit(event: "close"): booleanJump to headingemit(event: "data",chunk: Buffer | string,): booleanJump to headingemit(event: "drain"): booleanJump to headingemit(event: "end"): booleanJump to headingemit(event: "error",err: Error,): booleanJump to headingemit(event: "finish"): booleanJump to headingemit(event: "frameError",frameType: number,errorCode: number,): booleanJump to headingemit(event: "pipe",src: stream.Readable,): booleanJump to headingemit(event: "unpipe",src: stream.Readable,): booleanJump to headingemit(event: "streamClosed",code: number,): booleanJump to headingemit(event: "timeout"): booleanJump to headingemit(): booleanJump to headingemit(event: "wantTrailers"): booleanJump to headingemit(event: string | symbol,...args: any[],): booleanJump to headingon(event: "aborted",listener: () => void,): thisJump to headingon(event: "close",listener: () => void,): thisJump to headingon(event: "data",listener: (chunk: Buffer | string) => void,): thisJump to headingon(event: "drain",listener: () => void,): thisJump to headingon(event: "end",listener: () => void,): thisJump to headingon(event: "error",listener: (err: Error) => void,): thisJump to headingon(event: "finish",listener: () => void,): thisJump to headingon(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): thisJump to headingon(event: "pipe",listener: (src: stream.Readable) => void,): thisJump to headingon(event: "unpipe",listener: (src: stream.Readable) => void,): thisJump to headingon(event: "streamClosed",listener: (code: number) => void,): thisJump to headingon(event: "timeout",listener: () => void,): thisJump to headingon(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): thisJump to headingon(event: "wantTrailers",listener: () => void,): thisJump to headingon(event: string | symbol,listener: (...args: any[]) => void,): thisJump to headingonce(event: "aborted",listener: () => void,): thisJump to headingonce(event: "close",listener: () => void,): thisJump to headingonce(event: "data",listener: (chunk: Buffer | string) => void,): thisJump to headingonce(event: "drain",listener: () => void,): thisJump to headingonce(event: "end",listener: () => void,): thisJump to headingonce(event: "error",listener: (err: Error) => void,): thisJump to headingonce(event: "finish",listener: () => void,): thisJump to headingonce(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): thisJump to headingonce(event: "pipe",listener: (src: stream.Readable) => void,): thisJump to headingonce(event: "unpipe",listener: (src: stream.Readable) => void,): thisJump to headingonce(event: "streamClosed",listener: (code: number) => void,): thisJump to headingonce(event: "timeout",listener: () => void,): thisJump to headingonce(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): thisJump to headingonce(event: "wantTrailers",listener: () => void,): thisJump to headingonce(event: string | symbol,listener: (...args: any[]) => void,): thisJump to headingprependListener(event: "aborted",listener: () => void,): thisJump to headingprependListener(event: "close",listener: () => void,): thisJump to headingprependListener(event: "data",listener: (chunk: Buffer | string) => void,): thisJump to headingprependListener(event: "drain",listener: () => void,): thisJump to headingprependListener(event: "end",listener: () => void,): thisJump to headingprependListener(event: "error",listener: (err: Error) => void,): thisJump to headingprependListener(event: "finish",listener: () => void,): thisJump to headingprependListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): thisJump to headingprependListener(event: "pipe",listener: (src: stream.Readable) => void,): thisJump to headingprependListener(event: "unpipe",listener: (src: stream.Readable) => void,): thisJump to headingprependListener(event: "streamClosed",listener: (code: number) => void,): thisJump to headingprependListener(event: "timeout",listener: () => void,): thisJump to headingprependListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): thisJump to headingprependListener(event: "wantTrailers",listener: () => void,): thisJump to headingprependListener(event: string | symbol,listener: (...args: any[]) => void,): thisJump to headingprependOnceListener(event: "aborted",listener: () => void,): thisJump to headingprependOnceListener(event: "close",listener: () => void,): thisJump to headingprependOnceListener(event: "data",listener: (chunk: Buffer | string) => void,): thisJump to headingprependOnceListener(event: "drain",listener: () => void,): thisJump to headingprependOnceListener(event: "end",listener: () => void,): thisJump to headingprependOnceListener(event: "error",listener: (err: Error) => void,): thisJump to headingprependOnceListener(event: "finish",listener: () => void,): thisJump to headingprependOnceListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): thisJump to headingprependOnceListener(event: "pipe",listener: (src: stream.Readable) => void,): thisJump to headingprependOnceListener(event: "unpipe",listener: (src: stream.Readable) => void,): thisJump to headingprependOnceListener(event: "streamClosed",listener: (code: number) => void,): thisJump to headingprependOnceListener(event: "timeout",listener: () => void,): thisJump to headingprependOnceListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): thisJump to headingprependOnceListener(event: "wantTrailers",listener: () => void,): thisJump to headingprependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this