Skip to main content
ServerHttp2Stream.pushStream - http2 - Node documentation
method ServerHttp2Stream.pushStream

Usage in Deno

import { type ServerHttp2Stream } from "node:http2";
ServerHttp2Stream.pushStream(
callback?: (
err: Error | null,
pushStream: ServerHttp2Stream,
) => void
,
): void

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.

import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
  stream.respond({ ':status': 200 });
  stream.pushStream({ ':path': '/' }, (err, pushStream, headers) => {
    if (err) throw err;
    pushStream.respond({ ':status': 200 });
    pushStream.end('some pushed data');
  });
  stream.end('some data');
});

Setting the weight of a push stream is not allowed in the HEADERS frame. Pass a weight value to http2stream.priority with the silent option set to true to enable server-side bandwidth balancing between concurrent streams.

Calling http2stream.pushStream() from within a pushed stream is not permitted and will throw an error.

Parameters

optional
callback: (
err: Error | null,
pushStream: ServerHttp2Stream,
) => void

Callback that is called once the push stream has been initiated.

Return Type

void
ServerHttp2Stream.pushStream(
callback?: (
err: Error | null,
pushStream: ServerHttp2Stream,
) => void
,
): void

Parameters

optional
options: StreamPriorityOptions
optional
callback: (
err: Error | null,
pushStream: ServerHttp2Stream,
) => void

Return Type

void
Back to top