http2
The node:http2 module provides an implementation of the HTTP/2 protocol.
It can be accessed using:
import http2 from 'node:http2';
Usage in Deno
import * as mod from "node:http2";
Classes
A Http2ServerRequest object is created by Server or SecureServer and passed as the first argument to the 'request' event. It may be used to access a request status,
headers, and
data.
This object is created internally by an HTTP server, not by the user. It is
passed as the second parameter to the 'request' event.
Functions
Interfaces
- accept
- accept-charset
- accept-encoding
- accept-language
- accept-ranges
- access-control-allow-credentials
- access-control-allow-headers
- access-control-allow-methods
- access-control-allow-origin
- access-control-expose-headers
- access-control-max-age
- access-control-request-headers
- access-control-request-method
- age
- allow
- authorization
- cache-control
- cdn-cache-control
- connection
- content-disposition
- content-encoding
- content-language
- content-length
- content-location
- content-range
- content-security-policy
- content-security-policy-report-only
- content-type
- cookie
- date
- dav
- dnt
- etag
- expect
- expires
- forwarded
- from
- host
- if-match
- if-modified-since
- if-none-match
- if-range
- if-unmodified-since
- last-modified
- link
- location
- max-forwards
- origin
- pragma
- proxy-authenticate
- proxy-authorization
- public-key-pins
- public-key-pins-report-only
- range
- referer
- referrer-policy
- refresh
- retry-after
- sec-websocket-accept
- sec-websocket-extensions
- sec-websocket-key
- sec-websocket-protocol
- sec-websocket-version
- server
- set-cookie
- strict-transport-security
- te
- trailer
- transfer-encoding
- upgrade
- upgrade-insecure-requests
- user-agent
- vary
- via
- warning
- www-authenticate
- x-content-type-options
- x-dns-prefetch-control
- x-frame-options
- x-xss-protection
Namespaces
Variables
This symbol can be set as a property on the HTTP/2 headers object with an array value in order to provide a list of headers considered sensitive.
class Http2ServerRequest
Usage in Deno
import { Http2ServerRequest } from "node:http2";
A Http2ServerRequest object is created by Server or SecureServer and passed as the first argument to the 'request' event. It may be used to access a request status,
headers, and
data.
Constructors #
#Http2ServerRequest(stream: ServerHttp2Stream,headers: IncomingHttpHeaders,options: stream.ReadableOptions,rawHeaders: readonly string[],) Properties #
The request.aborted property will be true if the request has
been aborted.
The request authority pseudo header field. Because HTTP/2 allows requests
to set either :authority or host, this value is derived from req.headers[':authority'] if present. Otherwise, it is derived from req.headers['host'].
The request.complete property will be true if the request has
been completed, aborted, or destroyed.
#connection: net.Socket | tls.TLSSocket See request.socket.
#headers: IncomingHttpHeaders The request/response headers object.
Key-value pairs of header names and values. Header names are lower-cased.
// Prints something like:
//
// { 'user-agent': 'curl/7.22.0',
// host: '127.0.0.1:8000',
// accept: '*' }
console.log(request.headers);
See HTTP/2 Headers Object.
In HTTP/2, the request path, host name, protocol, and method are represented as
special headers prefixed with the : character (e.g. ':path'). These special
headers will be included in the request.headers object. Care must be taken not
to inadvertently modify these special headers or errors may occur. For instance,
removing all headers from the request will cause errors to occur:
removeAllHeaders(request.headers);
assert(request.url); // Fails because the :path header has been removed
#httpVersion: string In case of server request, the HTTP version sent by the client. In the case of
client response, the HTTP version of the connected-to server. Returns '2.0'.
Also message.httpVersionMajor is the first integer and message.httpVersionMinor is the second.
#httpVersionMajor: number #httpVersionMinor: number #rawHeaders: string[] The raw request/response headers list exactly as they were received.
The keys and values are in the same list. It is not a list of tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values.
Header names are not lowercased, and duplicates are not merged.
// Prints something like:
//
// [ 'user-agent',
// 'this is invalid because there can be only one',
// 'User-Agent',
// 'curl/7.22.0',
// 'Host',
// '127.0.0.1:8000',
// 'ACCEPT',
// '*' ]
console.log(request.rawHeaders);
#rawTrailers: string[] The raw request/response trailer keys and values exactly as they were
received. Only populated at the 'end' event.
The request scheme pseudo header field indicating the scheme portion of the target URL.
Returns a Proxy object that acts as a net.Socket (or tls.TLSSocket) but
applies getters, setters, and methods based on HTTP/2 logic.
destroyed, readable, and writable properties will be retrieved from and
set on request.stream.
destroy, emit, end, on and once methods will be called on request.stream.
setTimeout method will be called on request.stream.session.
pause, read, resume, and write will throw an error with code ERR_HTTP2_NO_SOCKET_MANIPULATION. See Http2Session and Sockets for
more information.
All other interactions will be routed directly to the socket. With TLS support,
use request.socket.getPeerCertificate() to obtain the client's
authentication details.
#stream: ServerHttp2Stream The Http2Stream object backing the request.
#trailers: IncomingHttpHeaders The request/response trailers object. Only populated at the 'end' event.
Request URL string. This contains only the URL that is present in the actual HTTP request. If the request is:
GET /status?name=ryan HTTP/1.1
Accept: text/plain
Then request.url will be:
'/status?name=ryan'
To parse the url into its parts, new URL() can be used:
$ node
> new URL('/status?name=ryan', 'http://example.com')
URL {
href: 'http://example.com/status?name=ryan',
origin: 'http://example.com',
protocol: 'http:',
username: '',
password: '',
host: 'example.com',
hostname: 'example.com',
port: '',
pathname: '/status',
search: '?name=ryan',
searchParams: URLSearchParams { 'name' => 'ryan' },
hash: ''
}
Methods #
#addListener(event: "aborted",listener: (hadError: boolean,code: number,) => void,): this #addListener(event: "close",listener: () => void,): this #addListener(event: "data",listener: (chunk: Buffer | string) => void,): this #addListener(event: "end",listener: () => void,): this #addListener(event: "readable",listener: () => void,): this #addListener(event: "error",listener: (err: Error) => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependListener(event: "aborted",listener: (hadError: boolean,code: number,) => void,): this #prependListener(event: "close",listener: () => void,): this #prependListener(event: "data",listener: (chunk: Buffer | string) => void,): this #prependListener(event: "end",listener: () => void,): this #prependListener(event: "readable",listener: () => void,): this #prependListener(event: "error",listener: (err: Error) => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "aborted",listener: (hadError: boolean,code: number,) => void,): this #prependOnceListener(event: "close",listener: () => void,): this #prependOnceListener(event: "data",listener: (chunk: Buffer | string) => void,): this #prependOnceListener(event: "end",listener: () => void,): this #prependOnceListener(event: "readable",listener: () => void,): this #prependOnceListener(event: "error",listener: (err: Error) => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this #setTimeout(msecs: number,callback?: () => void,): void Sets the Http2Stream's timeout value to msecs. If a callback is
provided, then it is added as a listener on the 'timeout' event on
the response object.
If no 'timeout' listener is added to the request, the response, or
the server, then Http2Streams are destroyed when they time out. If a
handler is assigned to the request, the response, or the server's 'timeout'events, timed out sockets must be handled explicitly.
class Http2ServerResponse
Usage in Deno
import { Http2ServerResponse } from "node:http2";
This object is created internally by an HTTP server, not by the user. It is
passed as the second parameter to the 'request' event.
Constructors #
#Http2ServerResponse(stream: ServerHttp2Stream) Type Parameters #
#Request extends Http2ServerRequest = Http2ServerRequest Properties #
#connection: net.Socket | tls.TLSSocket See response.socket.
Boolean value that indicates whether the response has completed. Starts
as false. After response.end() executes, the value will be true.
#headersSent: boolean True if headers were sent, false otherwise (read-only).
When true, the Date header will be automatically generated and sent in the response if it is not already present in the headers. Defaults to true.
This should only be disabled for testing; HTTP requires the Date header in responses.
Returns a Proxy object that acts as a net.Socket (or tls.TLSSocket) but
applies getters, setters, and methods based on HTTP/2 logic.
destroyed, readable, and writable properties will be retrieved from and
set on response.stream.
destroy, emit, end, on and once methods will be called on response.stream.
setTimeout method will be called on response.stream.session.
pause, read, resume, and write will throw an error with code ERR_HTTP2_NO_SOCKET_MANIPULATION. See Http2Session and Sockets for
more information.
All other interactions will be routed directly to the socket.
import http2 from 'node:http2';
const server = http2.createServer((req, res) => {
const ip = req.socket.remoteAddress;
const port = req.socket.remotePort;
res.end(`Your IP address is ${ip} and your source port is ${port}.`);
}).listen(3000);
#statusCode: number When using implicit headers (not calling response.writeHead() explicitly),
this property controls the status code that will be sent to the client when
the headers get flushed.
response.statusCode = 404;
After response header was sent to the client, this property indicates the status code which was sent out.
#statusMessage: "" Status message is not supported by HTTP/2 (RFC 7540 8.1.2.4). It returns an empty string.
#stream: ServerHttp2Stream The Http2Stream object backing the response.
Methods #
#addListener(event: "close",listener: () => void,): this #addListener(event: "drain",listener: () => void,): this #addListener(event: "error",listener: (error: Error) => void,): this #addListener(event: "finish",listener: () => void,): this #addListener(event: "pipe",listener: (src: stream.Readable) => void,): this #addListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #addTrailers(trailers: OutgoingHttpHeaders): void This method adds HTTP trailing headers (a header but at the end of the message) to the response.
Attempting to set a header field name or value that contains invalid characters
will result in a TypeError being thrown.
#appendHeader(name: string,value: string | string[],): void Append a single header value to the header object.
If the value is an array, this is equivalent to calling this method multiple times.
If there were no previous values for the header, this is equivalent to calling setHeader.
Attempting to set a header field name or value that contains invalid characters will result in a TypeError being thrown.
// Returns headers including "set-cookie: a" and "set-cookie: b"
const server = http2.createServer((req, res) => {
res.setHeader('set-cookie', 'a');
res.appendHeader('set-cookie', 'b');
res.writeHead(200);
res.end('ok');
});
#createPushResponse(headers: OutgoingHttpHeaders,callback: (err: Error | null,res: Http2ServerResponse,) => void,): void Call http2stream.pushStream() with the given headers, and wrap the
given Http2Stream on a newly created Http2ServerResponse as the callback
parameter if successful. When Http2ServerRequest is closed, the callback is
called with an error ERR_HTTP2_INVALID_STREAM.
This method signals to the server that all of the response headers and body
have been sent; that server should consider this message complete.
The method, response.end(), MUST be called on each response.
If data is specified, it is equivalent to calling response.write(data, encoding) followed by response.end(callback).
If callback is specified, it will be called when the response stream
is finished.
Reads out a header that has already been queued but not sent to the client. The name is case-insensitive.
const contentType = response.getHeader('content-type');
#getHeaderNames(): string[] Returns an array containing the unique names of the current outgoing headers. All header names are lowercase.
response.setHeader('Foo', 'bar');
response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
const headerNames = response.getHeaderNames();
// headerNames === ['foo', 'set-cookie']
Returns a shallow copy of the current outgoing headers. Since a shallow copy is used, array values may be mutated without additional calls to various header-related http module methods. The keys of the returned object are the header names and the values are the respective header values. All header names are lowercase.
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(),
obj.hasOwnProperty(), and others
are not defined and will not work.
response.setHeader('Foo', 'bar');
response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
const headers = response.getHeaders();
// headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
Returns true if the header identified by name is currently set in the
outgoing headers. The header name matching is case-insensitive.
const hasContentType = response.hasHeader('content-type');
#prependListener(event: "close",listener: () => void,): this #prependListener(event: "drain",listener: () => void,): this #prependListener(event: "error",listener: (error: Error) => void,): this #prependListener(event: "finish",listener: () => void,): this #prependListener(event: "pipe",listener: (src: stream.Readable) => void,): this #prependListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "close",listener: () => void,): this #prependOnceListener(event: "drain",listener: () => void,): this #prependOnceListener(event: "error",listener: (error: Error) => void,): this #prependOnceListener(event: "finish",listener: () => void,): this #prependOnceListener(event: "pipe",listener: (src: stream.Readable) => void,): this #prependOnceListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this #removeHeader(name: string): void Removes a header that has been queued for implicit sending.
response.removeHeader('Content-Encoding');
Sets a single header value for implicit headers. If this header already exists in the to-be-sent headers, its value will be replaced. Use an array of strings here to send multiple headers with the same name.
response.setHeader('Content-Type', 'text/html; charset=utf-8');
or
response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
Attempting to set a header field name or value that contains invalid characters
will result in a TypeError being thrown.
When headers have been set with response.setHeader(), they will be merged
with any headers passed to response.writeHead(), with the headers passed
to response.writeHead() given precedence.
// Returns content-type = text/plain
const server = http2.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.setHeader('X-Foo', 'bar');
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
res.end('ok');
});
#setTimeout(msecs: number,callback?: () => void,): void Sets the Http2Stream's timeout value to msecs. If a callback is
provided, then it is added as a listener on the 'timeout' event on
the response object.
If no 'timeout' listener is added to the request, the response, or
the server, then Http2Stream s are destroyed when they time out. If a
handler is assigned to the request, the response, or the server's 'timeout' events, timed out sockets must be handled explicitly.
If this method is called and response.writeHead() has not been called,
it will switch to implicit header mode and flush the implicit headers.
This sends a chunk of the response body. This method may be called multiple times to provide successive parts of the body.
In the node:http module, the response body is omitted when the
request is a HEAD request. Similarly, the 204 and 304 responses must not include a message body.
chunk can be a string or a buffer. If chunk is a string,
the second parameter specifies how to encode it into a byte stream.
By default the encoding is 'utf8'. callback will be called when this chunk
of data is flushed.
This is the raw HTTP body and has nothing to do with higher-level multi-part body encodings that may be used.
The first time response.write() is called, it will send the buffered
header information and the first chunk of the body to the client. The second
time response.write() is called, Node.js assumes data will be streamed,
and sends the new data separately. That is, the response is buffered up to the
first chunk of the body.
Returns true if the entire data was flushed successfully to the kernel
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.
#writeContinue(): void Sends a status 100 Continue to the client, indicating that the request body
should be sent. See the 'checkContinue' event on Http2Server and Http2SecureServer.
#writeEarlyHints(hints: Record<string, string | string[]>): void Sends a status 103 Early Hints to the client with a Link header,
indicating that the user agent can preload/preconnect the linked resources.
The hints is an object containing the values of headers to be sent with
early hints message.
Example
const earlyHintsLink = '</styles.css>; rel=preload; as=style';
response.writeEarlyHints({
'link': earlyHintsLink,
});
const earlyHintsLinks = [
'</styles.css>; rel=preload; as=style',
'</scripts.js>; rel=preload; as=script',
];
response.writeEarlyHints({
'link': earlyHintsLinks,
});
#writeHead(statusCode: number,headers?: OutgoingHttpHeaders,): this Sends a response header to the request. The status code is a 3-digit HTTP
status code, like 404. The last argument, headers, are the response headers.
Returns a reference to the Http2ServerResponse, so that calls can be chained.
For compatibility with HTTP/1, a human-readable statusMessage may be
passed as the second argument. However, because the statusMessage has no
meaning within HTTP/2, the argument will have no effect and a process warning
will be emitted.
const body = 'hello world';
response.writeHead(200, {
'Content-Length': Buffer.byteLength(body),
'Content-Type': 'text/plain; charset=utf-8',
});
Content-Length is given in bytes not characters. TheBuffer.byteLength() API may be used to determine the number of bytes in a
given encoding. On outbound messages, Node.js does not check if Content-Length
and the length of the body being transmitted are equal or not. However, when
receiving messages, Node.js will automatically reject messages when the Content-Length does not match the actual payload size.
This method may be called at most one time on a message before response.end() is called.
If response.write() or response.end() are called before calling
this, the implicit/mutable headers will be calculated and call this function.
When headers have been set with response.setHeader(), they will be merged
with any headers passed to response.writeHead(), with the headers passed
to response.writeHead() given precedence.
// Returns content-type = text/plain
const server = http2.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.setHeader('X-Foo', 'bar');
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
res.end('ok');
});
Attempting to set a header field name or value that contains invalid characters
will result in a TypeError being thrown.
function connect
Usage in Deno
import { connect } from "node:http2";
Overload 1
#connect(authority: string | url.URL,listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): ClientHttp2SessionReturns a ClientHttp2Session instance.
import http2 from 'node:http2';
const client = http2.connect('https://localhost:1234');
// Use the client
client.close();
Parameters #
#authority: string | url.URL 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
is used). Userinfo (user ID and password), path, querystring, and fragment details in the URL will be ignored.
#listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void Will be registered as a one-time listener of the 'connect' event.
Return Type #
Overload 2
#connect(authority: string | url.URL,options?: ClientSessionOptions | SecureClientSessionOptions,listener?: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): ClientHttp2SessionParameters #
#authority: string | url.URL #options: ClientSessionOptions | SecureClientSessionOptions #listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void Return Type #
function createSecureServer
Usage in Deno
import { createSecureServer } from "node:http2";
Overload 1
#createSecureServer(onRequestHandler?: (request: Http2ServerRequest,response: Http2ServerResponse,) => void): Http2SecureServerReturns a tls.Server instance that creates and manages Http2Session instances.
import http2 from 'node:http2';
import fs from 'node:fs';
const options = {
key: fs.readFileSync('server-key.pem'),
cert: fs.readFileSync('server-cert.pem'),
};
// Create a secure HTTP/2 server
const server = http2.createSecureServer(options);
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'text/html; charset=utf-8',
':status': 200,
});
stream.end('<h1>Hello World</h1>');
});
server.listen(8443);
Parameters #
#onRequestHandler: (request: Http2ServerRequest,response: Http2ServerResponse,) => void See Compatibility API
Return Type #
Overload 2
#createSecureServer<Http1Request extends IncomingMessage = IncomingMessage,Http1Response extends ServerResponse = ServerResponse,Http2Request extends Http2ServerRequest = Http2ServerRequest,Http2Response extends Http2ServerResponse = Http2ServerResponse,>(options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,onRequestHandler?: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Parameters #
#onRequestHandler: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void Return Type #
function createServer
Usage in Deno
import { createServer } from "node:http2";
Overload 1
#createServer(onRequestHandler?: (request: Http2ServerRequest,response: Http2ServerResponse,) => void): Http2ServerReturns a net.Server instance that creates and manages Http2Session instances.
Since there are no browsers known that support unencrypted HTTP/2, the use of createSecureServer is necessary when communicating with browser clients.
import http2 from 'node:http2';
// Create an unencrypted HTTP/2 server.
// Since there are no browsers known that support
// unencrypted HTTP/2, the use of `http2.createSecureServer()`
// is necessary when communicating with browser clients.
const server = http2.createServer();
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'text/html; charset=utf-8',
':status': 200,
});
stream.end('<h1>Hello World</h1>');
});
server.listen(8000);
Parameters #
#onRequestHandler: (request: Http2ServerRequest,response: Http2ServerResponse,) => void See Compatibility API
Return Type #
Overload 2
#createServer<Http1Request extends IncomingMessage = IncomingMessage,Http1Response extends ServerResponse = ServerResponse,Http2Request extends Http2ServerRequest = Http2ServerRequest,Http2Response extends Http2ServerResponse = Http2ServerResponse,>(options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,onRequestHandler?: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Parameters #
#options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response> #onRequestHandler: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void Return Type #
function getDefaultSettings
Usage in Deno
import { getDefaultSettings } from "node:http2";
function getPackedSettings
Usage in Deno
import { getPackedSettings } from "node:http2";
#getPackedSettings(settings: Settings): Buffer
This function is a non-functional stub.
Returns a Buffer instance containing serialized representation of the given
HTTP/2 settings as specified in the HTTP/2 specification. This is intended
for use with the HTTP2-Settings header field.
import http2 from 'node:http2';
const packed = http2.getPackedSettings({ enablePush: false });
console.log(packed.toString('base64'));
// Prints: AAIAAAAA
Parameters #
Return Type #
Buffer function getUnpackedSettings
Usage in Deno
import { getUnpackedSettings } from "node:http2";
function performServerHandshake
Usage in Deno
import { performServerHandshake } from "node:http2";
#performServerHandshake<Http1Request extends IncomingMessage = IncomingMessage,Http1Response extends ServerResponse = ServerResponse,Http2Request extends Http2ServerRequest = Http2ServerRequest,Http2Response extends Http2ServerResponse = Http2ServerResponse,>(socket: stream.Duplex,options?: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,): ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>Create an HTTP/2 server session from an existing socket.
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Parameters #
#socket: stream.Duplex A Duplex Stream
#options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response> Any [createServer](/api/node/http2/ options can be provided.
Return Type #
interface AlternativeServiceOptions
Usage in Deno
import { type AlternativeServiceOptions } from "node:http2";
interface ClientHttp2Session
Usage in Deno
import { type ClientHttp2Session } from "node:http2";
Methods #
#request(headers?: OutgoingHttpHeaders,options?: ClientSessionRequestOptions,): ClientHttp2Stream For HTTP/2 Client Http2Session instances only, the http2session.request() creates and returns an Http2Stream instance that can be used to send an
HTTP/2 request to the connected server.
When a ClientHttp2Session is first created, the socket may not yet be
connected. if clienthttp2session.request() is called during this time, the
actual request will be deferred until the socket is ready to go.
If the session is closed before the actual request be executed, an ERR_HTTP2_GOAWAY_SESSION is thrown.
This method is only available if http2session.type is equal to http2.constants.NGHTTP2_SESSION_CLIENT.
import http2 from 'node:http2';
const clientSession = http2.connect('https://localhost:1234');
const {
HTTP2_HEADER_PATH,
HTTP2_HEADER_STATUS,
} = http2.constants;
const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
req.on('response', (headers) => {
console.log(headers[HTTP2_HEADER_STATUS]);
req.on('data', (chunk) => { // .. });
req.on('end', () => { // .. });
});
When the options.waitForTrailers option is set, the 'wantTrailers' event
is emitted immediately after queuing the last chunk of payload data to be sent.
The http2stream.sendTrailers() method can then be called to send trailing
headers to the peer.
When options.waitForTrailers is set, the Http2Stream will not automatically
close when the final DATA frame is transmitted. User code must call eitherhttp2stream.sendTrailers() or http2stream.close() to close theHttp2Stream.
When options.signal is set with an AbortSignal and then abort on the
corresponding AbortController is called, the request will emit an 'error'event with an AbortError error.
The :method and :path pseudo-headers are not specified within headers,
they respectively default to:
:method='GET':path=/
#addListener(event: "altsvc",listener: (alt: string,origin: string,stream: number,) => void,): this #addListener(event: "origin",listener: (origins: string[]) => void,): this #addListener(event: "connect",listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): this #addListener(event: "stream",listener: () => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #emit(event: "stream",stream: ClientHttp2Stream,headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,): boolean #on(event: "connect",listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): this #once(event: "connect",listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): this #prependListener(event: "altsvc",listener: (alt: string,origin: string,stream: number,) => void,): this #prependListener(event: "origin",listener: (origins: string[]) => void,): this #prependListener(event: "connect",listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): this #prependListener(event: "stream",listener: () => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "altsvc",listener: (alt: string,origin: string,stream: number,) => void,): this #prependOnceListener(event: "origin",listener: (origins: string[]) => void,): this #prependOnceListener(event: "connect",listener: (session: ClientHttp2Session,socket: net.Socket | tls.TLSSocket,) => void,): this #prependOnceListener(event: "stream",listener: () => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface ClientHttp2Stream
Usage in Deno
import { type ClientHttp2Stream } from "node:http2";
All methods are non-functional stubs.
Methods #
#addListener(event: "continue",listener: () => { },): this #addListener(event: "headers",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #addListener(event: "push",listener: (headers: IncomingHttpHeaders,flags: number,) => void,): this #addListener(event: "response",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #on(event: "headers",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #on(event: "push",listener: (headers: IncomingHttpHeaders,flags: number,) => void,): this #on(event: "response",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #once(event: "headers",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #once(event: "push",listener: (headers: IncomingHttpHeaders,flags: number,) => void,): this #once(event: "response",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #prependListener(event: "continue",listener: () => { },): this #prependListener(event: "headers",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #prependListener(event: "push",listener: (headers: IncomingHttpHeaders,flags: number,) => void,): this #prependListener(event: "response",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "continue",listener: () => { },): this #prependOnceListener(event: "headers",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #prependOnceListener(event: "push",listener: (headers: IncomingHttpHeaders,flags: number,) => void,): this #prependOnceListener(event: "response",listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader,flags: number,) => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface ClientSessionOptions
Usage in Deno
import { type ClientSessionOptions } from "node:http2";
Properties #
#maxReservedRemoteStreams: number | undefined #createConnection: ((authority: url.URL,option: SessionOptions,) => stream.Duplex) | undefined interface ClientSessionRequestOptions
Usage in Deno
import { type ClientSessionRequestOptions } from "node:http2";
interface Http2SecureServer
Usage in Deno
import { type Http2SecureServer } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Methods #
#addListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #addListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #addListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #addListener(event: "sessionError",listener: (err: Error) => void,): this #addListener(event: "stream",listener: () => void,): this #addListener(event: "timeout",listener: () => void,): this #addListener(event: "unknownProtocol",listener: (socket: tls.TLSSocket) => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #emit(event: "session",session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,): boolean #on(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #on(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #on(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #once(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #once(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #once(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependListener(event: "sessionError",listener: (err: Error) => void,): this #prependListener(event: "stream",listener: () => void,): this #prependListener(event: "timeout",listener: () => void,): this #prependListener(event: "unknownProtocol",listener: (socket: tls.TLSSocket) => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependOnceListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependOnceListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependOnceListener(event: "sessionError",listener: (err: Error) => void,): this #prependOnceListener(event: "stream",listener: () => void,): this #prependOnceListener(event: "timeout",listener: () => void,): this #prependOnceListener(event: "unknownProtocol",listener: (socket: tls.TLSSocket) => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface Http2Server
Usage in Deno
import { type Http2Server } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Methods #
#addListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #addListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #addListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #addListener(event: "sessionError",listener: (err: Error) => void,): this #addListener(event: "stream",listener: () => void,): this #addListener(event: "timeout",listener: () => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #emit(event: "session",session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,): boolean #on(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #on(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #on(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #once(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #once(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #once(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependListener(event: "sessionError",listener: (err: Error) => void,): this #prependListener(event: "stream",listener: () => void,): this #prependListener(event: "timeout",listener: () => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "checkContinue",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependOnceListener(event: "request",listener: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): this #prependOnceListener(event: "session",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>) => void,): this #prependOnceListener(event: "sessionError",listener: (err: Error) => void,): this #prependOnceListener(event: "stream",listener: () => void,): this #prependOnceListener(event: "timeout",listener: () => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface HTTP2ServerCommon
Usage in Deno
import { type HTTP2ServerCommon } from "node:http2";
Methods #
#setTimeout(msec?: number,callback?: () => void,): this #updateSettings(settings: Settings): void Throws ERR_HTTP2_INVALID_SETTING_VALUE for invalid settings values. Throws ERR_INVALID_ARG_TYPE for invalid settings argument.
interface Http2Session
Usage in Deno
import { type Http2Session } from "node:http2";
The following methods are non-functional stubs:
- setLocalWindowSize
- ping
- localSettings
- remoteSettings
- settings
- ref
- unref
Properties #
#alpnProtocol: string | undefined Value will be undefined if the Http2Session is not yet connected to a
socket, h2c if the Http2Session is not connected to a TLSSocket, or
will return the value of the connected TLSSocket's own alpnProtocol property.
Will be true if this Http2Session instance has been closed, otherwise false.
#connecting: boolean Will be true if this Http2Session instance is still connecting, will be set
to false before emitting connect event and/or calling the http2.connect callback.
Will be true if this Http2Session instance has been destroyed and must no
longer be used, otherwise false.
Value is undefined if the Http2Session session socket has not yet been
connected, true if the Http2Session is connected with a TLSSocket,
and false if the Http2Session is connected to any other kind of socket
or stream.
#localSettings: Settings A prototype-less object describing the current local settings of this Http2Session.
The local settings are local to thisHttp2Session instance.
If the Http2Session is connected to a TLSSocket, the originSet property
will return an Array of origins for which the Http2Session may be
considered authoritative.
The originSet property is only available when using a secure TLS connection.
#pendingSettingsAck: boolean Indicates whether the Http2Session is currently waiting for acknowledgment of
a sent SETTINGS frame. Will be true after calling the http2session.settings() method.
Will be false once all sent SETTINGS frames have been acknowledged.
#remoteSettings: Settings A prototype-less object describing the current remote settings of thisHttp2Session.
The remote settings are set by the connected HTTP/2 peer.
Returns a Proxy object that acts as a net.Socket (or tls.TLSSocket) but
limits available methods to ones safe to use with HTTP/2.
destroy, emit, end, pause, read, resume, and write will throw
an error with code ERR_HTTP2_NO_SOCKET_MANIPULATION. See Http2Session and Sockets for more information.
setTimeout method will be called on this Http2Session.
All other interactions will be routed directly to the socket.
#state: SessionState Provides miscellaneous information about the current state of theHttp2Session.
An object describing the current status of this Http2Session.
Methods #
Gracefully closes the Http2Session, allowing any existing streams to
complete on their own and preventing new Http2Stream instances from being
created. Once closed, http2session.destroy()might be called if there
are no open Http2Stream instances.
If specified, the callback function is registered as a handler for the'close' event.
Immediately terminates the Http2Session and the associated net.Socket or tls.TLSSocket.
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.
If there are any remaining open Http2Streams associated with the Http2Session, those will also be destroyed.
Transmits a GOAWAY frame to the connected peer without shutting down theHttp2Session.
Sends a PING frame to the connected HTTP/2 peer. A callback function must
be provided. The method will return true if the PING was sent, false otherwise.
The maximum number of outstanding (unacknowledged) pings is determined by the maxOutstandingPings configuration option. The default maximum is 10.
If provided, the payload must be a Buffer, TypedArray, or DataView containing 8 bytes of data that will be transmitted with the PING and
returned with the ping acknowledgment.
The callback will be invoked with three arguments: an error argument that will
be null if the PING was successfully acknowledged, a duration argument
that reports the number of milliseconds elapsed since the ping was sent and the
acknowledgment was received, and a Buffer containing the 8-byte PING payload.
session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
if (!err) {
console.log(`Ping acknowledged in ${duration} milliseconds`);
console.log(`With payload '${payload.toString()}'`);
}
});
If the payload argument is not specified, the default payload will be the
64-bit timestamp (little endian) marking the start of the PING duration.
#setLocalWindowSize(windowSize: number): void Sets the local endpoint's window size.
The windowSize is the total window size to set, not
the delta.
import http2 from 'node:http2';
const server = http2.createServer();
const expectedWindowSize = 2 ** 20;
server.on('connect', (session) => {
// Set local window size to be 2 ** 20
session.setLocalWindowSize(expectedWindowSize);
});
#setTimeout(msecs: number,callback?: () => void,): void Used to set a callback function that is called when there is no activity on
the Http2Session after msecs milliseconds. The given callback is
registered as a listener on the 'timeout' event.
Updates the current local settings for this Http2Session and sends a new SETTINGS frame to the connected HTTP/2 peer.
Once called, the http2session.pendingSettingsAck property will be true while the session is waiting for the remote peer to acknowledge the new
settings.
The new settings will not become effective until the SETTINGS acknowledgment
is received and the 'localSettings' event is emitted. It is possible to send
multiple SETTINGS frames while acknowledgment is still pending.
#addListener(event: "close",listener: () => void,): this #addListener(event: "error",listener: (err: Error) => void,): this #addListener(event: "frameError",listener: (frameType: number,errorCode: number,streamID: number,) => void,): this #addListener(event: "goaway",listener: (errorCode: number,lastStreamID: number,opaqueData?: Buffer,) => void,): this #addListener(event: "localSettings",listener: (settings: Settings) => void,): this #addListener(event: "ping",listener: () => void,): this #addListener(event: "remoteSettings",listener: (settings: Settings) => void,): this #addListener(event: "timeout",listener: () => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependListener(event: "close",listener: () => void,): this #prependListener(event: "error",listener: (err: Error) => void,): this #prependListener(event: "frameError",listener: (frameType: number,errorCode: number,streamID: number,) => void,): this #prependListener(event: "goaway",listener: (errorCode: number,lastStreamID: number,opaqueData?: Buffer,) => void,): this #prependListener(event: "localSettings",listener: (settings: Settings) => void,): this #prependListener(event: "ping",listener: () => void,): this #prependListener(event: "remoteSettings",listener: (settings: Settings) => void,): this #prependListener(event: "timeout",listener: () => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "close",listener: () => void,): this #prependOnceListener(event: "error",listener: (err: Error) => void,): this #prependOnceListener(event: "frameError",listener: (frameType: number,errorCode: number,streamID: number,) => void,): this #prependOnceListener(event: "goaway",listener: (errorCode: number,lastStreamID: number,opaqueData?: Buffer,) => void,): this #prependOnceListener(event: "localSettings",listener: (settings: Settings) => void,): this #prependOnceListener(event: "ping",listener: () => void,): this #prependOnceListener(event: "remoteSettings",listener: (settings: Settings) => void,): this #prependOnceListener(event: "timeout",listener: () => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface Http2Stream
Usage in Deno
import { type Http2Stream } from "node:http2";
The following methods are non-functional stubs:
- aborted
- bufferSize
- endAfterHeaders
- id
- pending
- priority
- rstCode
- sentHeaders
- sentInfoHeaders
- sentTrailers
- state
Properties #
Set to true if the Http2Stream instance was aborted abnormally. When set,
the 'aborted' event will have been emitted.
#bufferSize: number This property shows the number of characters currently buffered to be written.
See net.Socket.bufferSize for details.
Set to true if the Http2Stream instance has been destroyed and is no longer
usable.
#endAfterHeaders: boolean Set 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.
The numeric stream identifier of this Http2Stream instance. Set to undefined if the stream identifier has not yet been assigned.
Set to true if the Http2Stream instance has not yet been assigned a
numeric stream identifier.
Set 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.
#sentHeaders: OutgoingHttpHeaders An object containing the outbound headers sent for this Http2Stream.
#sentInfoHeaders: OutgoingHttpHeaders[] | undefined An array of objects containing the outbound informational (additional) headers
sent for this Http2Stream.
#sentTrailers: OutgoingHttpHeaders | undefined An object containing the outbound trailers sent for this HttpStream.
#session: Http2Session | undefined A reference to the Http2Session instance that owns this Http2Stream. The
value will be undefined after the Http2Stream instance is destroyed.
#state: StreamState Provides miscellaneous information about the current state of the Http2Stream.
A current state of this Http2Stream.
Methods #
Closes the Http2Stream instance by sending an RST_STREAM frame to the
connected HTTP/2 peer.
#priority(options: StreamPriorityOptions): void Updates the priority for this Http2Stream instance.
#setTimeout(msecs: number,callback?: () => void,): void import 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));
#sendTrailers(headers: OutgoingHttpHeaders): void Sends 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).
#addListener(event: "aborted",listener: () => void,): this #addListener(event: "close",listener: () => void,): this #addListener(event: "data",listener: (chunk: Buffer | string) => void,): this #addListener(event: "drain",listener: () => void,): this #addListener(event: "end",listener: () => void,): this #addListener(event: "error",listener: (err: Error) => void,): this #addListener(event: "finish",listener: () => void,): this #addListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): this #addListener(event: "pipe",listener: (src: stream.Readable) => void,): this #addListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #addListener(event: "streamClosed",listener: (code: number) => void,): this #addListener(event: "timeout",listener: () => void,): this #addListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): this #addListener(event: "wantTrailers",listener: () => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #on(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): this #once(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): this #prependListener(event: "aborted",listener: () => void,): this #prependListener(event: "close",listener: () => void,): this #prependListener(event: "data",listener: (chunk: Buffer | string) => void,): this #prependListener(event: "drain",listener: () => void,): this #prependListener(event: "end",listener: () => void,): this #prependListener(event: "error",listener: (err: Error) => void,): this #prependListener(event: "finish",listener: () => void,): this #prependListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): this #prependListener(event: "pipe",listener: (src: stream.Readable) => void,): this #prependListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #prependListener(event: "streamClosed",listener: (code: number) => void,): this #prependListener(event: "timeout",listener: () => void,): this #prependListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): this #prependListener(event: "wantTrailers",listener: () => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "aborted",listener: () => void,): this #prependOnceListener(event: "close",listener: () => void,): this #prependOnceListener(event: "data",listener: (chunk: Buffer | string) => void,): this #prependOnceListener(event: "drain",listener: () => void,): this #prependOnceListener(event: "end",listener: () => void,): this #prependOnceListener(event: "error",listener: (err: Error) => void,): this #prependOnceListener(event: "finish",listener: () => void,): this #prependOnceListener(event: "frameError",listener: (frameType: number,errorCode: number,) => void,): this #prependOnceListener(event: "pipe",listener: (src: stream.Readable) => void,): this #prependOnceListener(event: "unpipe",listener: (src: stream.Readable) => void,): this #prependOnceListener(event: "streamClosed",listener: (code: number) => void,): this #prependOnceListener(event: "timeout",listener: () => void,): this #prependOnceListener(event: "trailers",listener: (trailers: IncomingHttpHeaders,flags: number,) => void,): this #prependOnceListener(event: "wantTrailers",listener: () => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface IncomingHttpHeaders
Usage in Deno
import { type IncomingHttpHeaders } from "node:http2";
interface IncomingHttpStatusHeader
Usage in Deno
import { type IncomingHttpStatusHeader } from "node:http2";
interface OutgoingHttpHeaders
Usage in Deno
import { type OutgoingHttpHeaders } from "node:http2";
Properties #
#accept: string
| string[]
| undefined #accept-charset: string
| string[]
| undefined #accept-encoding: string
| string[]
| undefined #accept-language: string
| string[]
| undefined #accept-ranges: string | undefined #access-control-allow-credentials: string | undefined #access-control-allow-headers: string | undefined #access-control-allow-methods: string | undefined #access-control-allow-origin: string | undefined #access-control-expose-headers: string | undefined #access-control-max-age: string | undefined #access-control-request-headers: string | undefined #access-control-request-method: string | undefined #age: string | undefined #allow: string | undefined #authorization: string | undefined #cache-control: string | undefined #cdn-cache-control: string | undefined #connection: string
| string[]
| undefined #content-disposition: string | undefined #content-encoding: string | undefined #content-language: string | undefined #content-length: string
| number
| undefined #content-location: string | undefined #content-range: string | undefined #content-security-policy: string | undefined #content-security-policy-report-only: string | undefined #content-type: string | undefined #cookie: string
| string[]
| undefined #dav: string
| string[]
| undefined #dnt: string | undefined #date: string | undefined #etag: string | undefined #expect: string | undefined #expires: string | undefined #forwarded: string | undefined #from: string | undefined #host: string | undefined #if-match: string | undefined #if-modified-since: string | undefined #if-none-match: string | undefined #if-range: string | undefined #if-unmodified-since: string | undefined #last-modified: string | undefined #link: string
| string[]
| undefined #location: string | undefined #max-forwards: string | undefined #origin: string | undefined #pragma: string
| string[]
| undefined #proxy-authenticate: string
| string[]
| undefined #proxy-authorization: string | undefined #public-key-pins: string | undefined #public-key-pins-report-only: string | undefined #range: string | undefined #referer: string | undefined #referrer-policy: string | undefined #refresh: string | undefined #retry-after: string | undefined #sec-websocket-accept: string | undefined #sec-websocket-extensions: string
| string[]
| undefined #sec-websocket-key: string | undefined #sec-websocket-protocol: string
| string[]
| undefined #sec-websocket-version: string | undefined #server: string | undefined #set-cookie: string
| string[]
| undefined #strict-transport-security: string | undefined #te: string | undefined #trailer: string | undefined #transfer-encoding: string | undefined #user-agent: string | undefined #upgrade: string | undefined #upgrade-insecure-requests: string | undefined #vary: string | undefined #via: string
| string[]
| undefined #warning: string | undefined #www-authenticate: string
| string[]
| undefined #x-content-type-options: string | undefined #x-dns-prefetch-control: string | undefined #x-frame-options: string | undefined #x-xss-protection: string | undefined interface SecureClientSessionOptions
Usage in Deno
import { type SecureClientSessionOptions } from "node:http2";
interface SecureServerOptions
Usage in Deno
import { type SecureServerOptions } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Properties #
#allowHTTP1: boolean | undefined interface SecureServerSessionOptions
Usage in Deno
import { type SecureServerSessionOptions } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse interface ServerHttp2Session
Usage in Deno
import { type ServerHttp2Session } from "node:http2";
All methods are non-functional stubs.
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Properties #
Methods #
Submits an ALTSVC frame (as defined by RFC 7838) to the connected client.
import http2 from 'node:http2';
const server = http2.createServer();
server.on('session', (session) => {
// Set altsvc for origin https://example.org:80
session.altsvc('h2=":8000"', 'https://example.org:80');
});
server.on('stream', (stream) => {
// Set altsvc for a specific stream
stream.session.altsvc('h2=":8000"', stream.id);
});
Sending an ALTSVC frame with a specific stream ID indicates that the alternate
service is associated with the origin of the given Http2Stream.
The alt and origin string must contain only ASCII bytes and are
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
domain.
When a string is passed for the originOrStream argument, it will be parsed as
a URL and the 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 string
cannot be parsed as a URL or if a valid origin cannot be derived.
A URL object, or any object with an origin property, may be passed asoriginOrStream, in which case the value of the origin property will be
used. The value of the origin property must be a properly serialized
ASCII origin.
Submits an ORIGIN frame (as defined by RFC 8336) to the connected client
to advertise the set of origins for which the server is capable of providing
authoritative responses.
import http2 from 'node:http2';
const options = getSecureOptionsSomehow();
const server = http2.createSecureServer(options);
server.on('stream', (stream) => {
stream.respond();
stream.end('ok');
});
server.on('session', (session) => {
session.origin('https://example.com', 'https://example.org');
});
When a string is passed as an origin, it will be parsed as a URL and the
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
string
cannot be parsed as a URL or if a valid origin cannot be derived.
A URL object, or any object with an origin property, may be passed as
an origin, in which case the value of the origin property will be
used. The value of the origin property must be a properly serialized
ASCII origin.
Alternatively, the origins option may be used when creating a new HTTP/2
server using the http2.createSecureServer() method:
import http2 from 'node:http2';
const options = getSecureOptionsSomehow();
options.origins = ['https://example.com', 'https://example.org'];
const server = http2.createSecureServer(options);
server.on('stream', (stream) => {
stream.respond();
stream.end('ok');
});
#addListener(event: "connect",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,) => void,): this #addListener(event: "stream",listener: () => void,): this #addListener(event: string | symbol,listener: (...args: any[]) => void,): this #emit(event: "connect",session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,): boolean #on(event: "connect",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,) => void,): this #once(event: "connect",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,) => void,): this #prependListener(event: "connect",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,) => void,): this #prependListener(event: "stream",listener: () => void,): this #prependListener(event: string | symbol,listener: (...args: any[]) => void,): this #prependOnceListener(event: "connect",listener: (session: ServerHttp2Session<Http1Request, Http1Response, Http2Request, Http2Response>,socket: net.Socket | tls.TLSSocket,) => void,): this #prependOnceListener(event: "stream",listener: () => void,): this #prependOnceListener(event: string | symbol,listener: (...args: any[]) => void,): this interface ServerHttp2Stream
Usage in Deno
import { type ServerHttp2Stream } from "node:http2";
Properties #
#headersSent: boolean True if headers were sent, false otherwise (read-only).
#pushAllowed: boolean Read-only property mapped to the SETTINGS_ENABLE_PUSH flag of the remote
client's most recent SETTINGS frame. Will be true if the remote peer
accepts push streams, false otherwise. Settings are the same for every Http2Stream in the same Http2Session.
Methods #
#additionalHeaders(headers: OutgoingHttpHeaders): void Sends an additional informational HEADERS frame to the connected HTTP/2 peer.
#pushStream(headers: OutgoingHttpHeaders,callback?: () => 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.
#pushStream(): void #respond(headers?: OutgoingHttpHeaders,options?: ServerStreamResponseOptions,): void import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond({ ':status': 200 });
stream.end('some data');
});
Initiates a response. When the options.waitForTrailers option is set, the 'wantTrailers' event
will be emitted immediately after queuing the last chunk of payload data to be sent.
The http2stream.sendTrailers() method can then be used to send trailing header fields to the peer.
When options.waitForTrailers is set, the Http2Stream will not automatically
close when the final DATA frame is transmitted. User code must call either http2stream.sendTrailers() or http2stream.close() to close the Http2Stream.
import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond({ ':status': 200 }, { waitForTrailers: true });
stream.on('wantTrailers', () => {
stream.sendTrailers({ ABC: 'some value to send' });
});
stream.end('some data');
});
#respondWithFD(fd: number | fs.promises.FileHandle,headers?: OutgoingHttpHeaders,options?: ServerStreamFileResponseOptions,): void Initiates a response whose data is read from the given file descriptor. No
validation is performed on the given file descriptor. If an error occurs while
attempting to read data using the file descriptor, the Http2Stream will be
closed using an RST_STREAM frame using the standard INTERNAL_ERROR code.
When used, the Http2Stream object's Duplex interface will be closed
automatically.
import http2 from 'node:http2';
import fs from 'node:fs';
const server = http2.createServer();
server.on('stream', (stream) => {
const fd = fs.openSync('/some/file', 'r');
const stat = fs.fstatSync(fd);
const headers = {
'content-length': stat.size,
'last-modified': stat.mtime.toUTCString(),
'content-type': 'text/plain; charset=utf-8',
};
stream.respondWithFD(fd, headers);
stream.on('close', () => fs.closeSync(fd));
});
The optional options.statCheck function may be specified to give user code
an opportunity to set additional content headers based on the fs.Stat details
of the given fd. If the statCheck function is provided, the http2stream.respondWithFD() method will
perform an fs.fstat() call to collect details on the provided file descriptor.
The offset and length options may be used to limit the response to a
specific range subset. This can be used, for instance, to support HTTP Range
requests.
The file descriptor or FileHandle is not closed when the stream is closed,
so it will need to be closed manually once it is no longer needed.
Using the same file descriptor concurrently for multiple streams
is not supported and may result in data loss. Re-using a file descriptor
after a stream has finished is supported.
When the options.waitForTrailers option is set, the 'wantTrailers' event
will be emitted immediately after queuing the last chunk of payload data to be
sent. The http2stream.sendTrailers() method can then be used to sent trailing
header fields to the peer.
When options.waitForTrailers is set, the Http2Stream will not automatically
close when the final DATA frame is transmitted. User code must call either http2stream.sendTrailers()
or http2stream.close() to close the Http2Stream.
import http2 from 'node:http2';
import fs from 'node:fs';
const server = http2.createServer();
server.on('stream', (stream) => {
const fd = fs.openSync('/some/file', 'r');
const stat = fs.fstatSync(fd);
const headers = {
'content-length': stat.size,
'last-modified': stat.mtime.toUTCString(),
'content-type': 'text/plain; charset=utf-8',
};
stream.respondWithFD(fd, headers, { waitForTrailers: true });
stream.on('wantTrailers', () => {
stream.sendTrailers({ ABC: 'some value to send' });
});
stream.on('close', () => fs.closeSync(fd));
});
#respondWithFile(): void Sends a regular file as the response. The path must specify a regular file
or an 'error' event will be emitted on the Http2Stream object.
When used, the Http2Stream object's Duplex interface will be closed
automatically.
The optional options.statCheck function may be specified to give user code
an opportunity to set additional content headers based on the fs.Stat details
of the given file:
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 defined, then it will be called. Otherwise, the stream will be destroyed.
Example using a file path:
import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
function statCheck(stat, headers) {
headers['last-modified'] = stat.mtime.toUTCString();
}
function onError(err) {
// stream.respond() can throw if the stream has been destroyed by
// the other side.
try {
if (err.code === 'ENOENT') {
stream.respond({ ':status': 404 });
} else {
stream.respond({ ':status': 500 });
}
} catch (err) {
// Perform actual error handling.
console.error(err);
}
stream.end();
}
stream.respondWithFile('/some/file',
{ 'content-type': 'text/plain; charset=utf-8' },
{ statCheck, onError });
});
The options.statCheck function may also be used to cancel the send operation
by returning false. For instance, a conditional request may check the stat
results to determine if the file has been modified to return an appropriate 304 response:
import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
function statCheck(stat, headers) {
// Check the stat here...
stream.respond({ ':status': 304 });
return false; // Cancel the send operation
}
stream.respondWithFile('/some/file',
{ 'content-type': 'text/plain; charset=utf-8' },
{ statCheck });
});
The content-length header field will be automatically set.
The offset and length options may be used to limit the response to a
specific range subset. This can be used, for instance, to support HTTP Range
requests.
The options.onError function may also be used to handle all the errors
that could happen before the delivery of the file is initiated. The
default behavior is to destroy the stream.
When the options.waitForTrailers option is set, the 'wantTrailers' event
will be emitted immediately after queuing the last chunk of payload data to be
sent. The http2stream.sendTrailers() method can then be used to sent trailing
header fields to the peer.
When options.waitForTrailers is set, the Http2Stream will not automatically
close when the final DATA frame is transmitted. User code must call eitherhttp2stream.sendTrailers() or http2stream.close() to close theHttp2Stream.
import http2 from 'node:http2';
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respondWithFile('/some/file',
{ 'content-type': 'text/plain; charset=utf-8' },
{ waitForTrailers: true });
stream.on('wantTrailers', () => {
stream.sendTrailers({ ABC: 'some value to send' });
});
});
interface ServerOptions
Usage in Deno
import { type ServerOptions } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Properties #
#streamResetBurst: number | undefined #streamResetRate: number | undefined interface ServerSessionOptions
Usage in Deno
import { type ServerSessionOptions } from "node:http2";
Type Parameters #
#Http1Request extends IncomingMessage = IncomingMessage #Http1Response extends ServerResponse = ServerResponse #Http2Request extends Http2ServerRequest = Http2ServerRequest #Http2Response extends Http2ServerResponse = Http2ServerResponse Properties #
#Http1IncomingMessage: Http1Request | undefined #Http1ServerResponse: Http1Response | undefined #Http2ServerRequest: Http2Request | undefined #Http2ServerResponse: Http2Response | undefined interface ServerStreamFileResponseOptions
Usage in Deno
import { type ServerStreamFileResponseOptions } from "node:http2";
interface ServerStreamFileResponseOptionsWithError
Usage in Deno
import { type ServerStreamFileResponseOptionsWithError } from "node:http2";
interface ServerStreamResponseOptions
Usage in Deno
import { type ServerStreamResponseOptions } from "node:http2";
Properties #
#waitForTrailers: boolean | undefined interface SessionOptions
Usage in Deno
import { type SessionOptions } from "node:http2";
Properties #
#maxDeflateDynamicTableSize: number | undefined #maxSessionMemory: number | undefined #maxHeaderListPairs: number | undefined #maxOutstandingPings: number | undefined #maxSendHeaderBlockLength: number | undefined #paddingStrategy: number | undefined #peerMaxConcurrentStreams: number | undefined #remoteCustomSettings: number[] | undefined #unknownProtocolTimeout: number | undefined Specifies a timeout in milliseconds that
a server should wait when an ['unknownProtocol'][] is emitted. If the
socket has not been destroyed by that time the server will destroy it.
Methods #
#selectPadding(frameLen: number,maxFrameLen: number,): number interface SessionState
Usage in Deno
import { type SessionState } from "node:http2";
Properties #
#effectiveLocalWindowSize: number | undefined #effectiveRecvDataLength: number | undefined #nextStreamID: number | undefined #localWindowSize: number | undefined #lastProcStreamID: number | undefined #remoteWindowSize: number | undefined #outboundQueueSize: number | undefined #deflateDynamicTableSize: number | undefined #inflateDynamicTableSize: number | undefined interface Settings
Usage in Deno
import { type Settings } from "node:http2";
Properties #
#headerTableSize: number | undefined #enablePush: boolean | undefined #initialWindowSize: number | undefined #maxFrameSize: number | undefined #maxConcurrentStreams: number | undefined #maxHeaderListSize: number | undefined #enableConnectProtocol: boolean | undefined interface StreamState
Usage in Deno
import { type StreamState } from "node:http2";
Properties #
#localWindowSize: number | undefined #localClose: number | undefined #remoteClose: number | undefined #sumDependencyWeight: number | undefined variable constants.DEFAULT_SETTINGS_ENABLE_PUSH
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.DEFAULT_SETTINGS_HEADER_TABLE_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.DEFAULT_SETTINGS_MAX_FRAME_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP2_HEADER_ACCEPT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCEPT_CHARSET
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCEPT_ENCODING
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCEPT_LANGUAGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCEPT_RANGES
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_AGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ALLOW
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_AUTHORITY
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_AUTHORIZATION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CACHE_CONTROL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONNECTION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_DISPOSITION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_ENCODING
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_LANGUAGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_LENGTH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_LOCATION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_MD5
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_RANGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_CONTENT_TYPE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_COOKIE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_DATE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_ETAG
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_EXPECT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_EXPIRES
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_FROM
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_HOST
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_HTTP2_SETTINGS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_IF_MATCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_IF_MODIFIED_SINCE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_IF_NONE_MATCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_IF_RANGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_IF_UNMODIFIED_SINCE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_KEEP_ALIVE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_LAST_MODIFIED
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_LINK
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_LOCATION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_MAX_FORWARDS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_METHOD
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_PATH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_PREFER
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_PROXY_AUTHENTICATE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_PROXY_AUTHORIZATION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_PROXY_CONNECTION
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_RANGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_REFERER
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_REFRESH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_RETRY_AFTER
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_SCHEME
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_SERVER
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_SET_COOKIE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_STATUS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_STRICT_TRANSPORT_SECURITY
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_TRANSFER_ENCODING
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_UPGRADE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_USER_AGENT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_VARY
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_VIA
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_HEADER_WWW_AUTHENTICATE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_ACL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_BASELINE_CONTROL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_BIND
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_CHECKIN
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_CHECKOUT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_CONNECT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_COPY
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_DELETE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_GET
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_HEAD
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_LABEL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_LINK
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_LOCK
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MERGE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MKACTIVITY
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MKCALENDAR
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MKCOL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MKREDIRECTREF
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MKWORKSPACE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_MOVE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_OPTIONS
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_ORDERPATCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_PATCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_POST
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_PRI
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_PROPFIND
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_PROPPATCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_PUT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_REBIND
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_REPORT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_SEARCH
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_TRACE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UNBIND
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UNCHECKOUT
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UNLINK
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UNLOCK
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UPDATE
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_UPDATEREDIRECTREF
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP2_METHOD_VERSION_CONTROL
Usage in Deno
import { constants } from "node:http2";
Type #
string variable constants.HTTP_STATUS_ACCEPTED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_ALREADY_REPORTED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_BAD_GATEWAY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_BAD_REQUEST
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_CONFLICT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_CONTINUE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_CREATED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_EXPECTATION_FAILED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_FAILED_DEPENDENCY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_FORBIDDEN
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_FOUND
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_GATEWAY_TIMEOUT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_GONE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_IM_USED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_INSUFFICIENT_STORAGE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_INTERNAL_SERVER_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_LENGTH_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_LOCKED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_LOOP_DETECTED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_METHOD_NOT_ALLOWED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_MISDIRECTED_REQUEST
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_MOVED_PERMANENTLY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_MULTI_STATUS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_MULTIPLE_CHOICES
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NO_CONTENT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NOT_ACCEPTABLE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NOT_EXTENDED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NOT_FOUND
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NOT_IMPLEMENTED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_NOT_MODIFIED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PARTIAL_CONTENT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PAYLOAD_TOO_LARGE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PAYMENT_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PERMANENT_REDIRECT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PRECONDITION_FAILED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PRECONDITION_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PROCESSING
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_RANGE_NOT_SATISFIABLE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_REQUEST_TIMEOUT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_RESET_CONTENT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_SEE_OTHER
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_SERVICE_UNAVAILABLE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_SWITCHING_PROTOCOLS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_TEAPOT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_TEMPORARY_REDIRECT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_TOO_MANY_REQUESTS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UNAUTHORIZED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UNORDERED_COLLECTION
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UNPROCESSABLE_ENTITY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_UPGRADE_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_URI_TOO_LONG
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_USE_PROXY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.HTTP_STATUS_VARIANT_ALSO_NEGOTIATES
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.MAX_INITIAL_WINDOW_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.MAX_MAX_FRAME_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.MIN_MAX_FRAME_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_COMPRESSION_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_CONNECT_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_DEFAULT_WEIGHT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_ENHANCE_YOUR_CALM
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_ERR_FRAME_SIZE_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_ACK
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_END_HEADERS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_END_STREAM
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_NONE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_PADDED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLAG_PRIORITY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FLOW_CONTROL_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_FRAME_SIZE_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_HTTP_1_1_REQUIRED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_INADEQUATE_SECURITY
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_INTERNAL_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_NO_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_PROTOCOL_ERROR
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_REFUSED_STREAM
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SESSION_CLIENT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SESSION_SERVER
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_ENABLE_PUSH
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_HEADER_TABLE_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_MAX_FRAME_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_SETTINGS_TIMEOUT
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_CLOSED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_CLOSED
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_IDLE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_OPEN
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_RESERVED_LOCAL
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.NGHTTP2_STREAM_STATE_RESERVED_REMOTE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.PADDING_STRATEGY_CALLBACK
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.PADDING_STRATEGY_MAX
Usage in Deno
import { constants } from "node:http2";
Type #
number variable constants.PADDING_STRATEGY_NONE
Usage in Deno
import { constants } from "node:http2";
Type #
number variable sensitiveHeaders
Usage in Deno
import { sensitiveHeaders } from "node:http2";
This symbol can be set as a property on the HTTP/2 headers object with an array value in order to provide a list of headers considered sensitive.
Type #
symbol