Usage in Deno
```typescript import * as mod from "node:node__http2.d.ts"; ```The `node:http2` module provides an implementation of the [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol.
It can be accessed using:
```js
import http2 from 'node:http2';
```
c
Http2ServerRequest
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.
c
Http2ServerResponse
This object is created internally by an HTTP server, not by the user. It is
passed as the second parameter to the `'request'` event.
f
connect
Returns a `ClientHttp2Session` instance.
```js
import http2 from 'node:http2';
const client = http2.connect('https://localhost:1234');
// Use the client
client.close();
```
f
createSecureServer
Returns a `tls.Server` instance that creates and manages `Http2Session` instances.
```js
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('
Hello World
'); }); server.listen(8443); ```f
createServer
Returns a `net.Server` instance that creates and manages `Http2Session` instances.
Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of [createSecureServer](.././node__http2.d.ts/~/createSecureServer) is necessary when
communicating
with browser clients.
```js
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('
Hello World
'); }); server.listen(8000); ```f
getDefaultSettings
> [!WARNING] Deno compatibility
> This function is a non-functional stub.
Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called
so instances returned may be safely modified for use.
f
getPackedSettings
> [!WARNING] Deno compatibility
> 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](https://tools.ietf.org/html/rfc7540) specification. This is intended
for use with the `HTTP2-Settings` header field.
```js
import http2 from 'node:http2';
const packed = http2.getPackedSettings({ enablePush: false });
console.log(packed.toString('base64'));
// Prints: AAIAAAAA
```
f
getUnpackedSettings
> [!WARNING] Deno compatibility
> This function is a non-functional stub.
Returns a `HTTP/2 Settings Object` containing the deserialized settings from
the given `Buffer` as generated by `http2.getPackedSettings()`.
f
performServerHandshake
Create an HTTP/2 server session from an existing socket.
I
I
ClientHttp2Session
No documentation available
I
ClientHttp2Stream
> [!WARNING] Deno compatibility
> All methods are non-functional stubs.
I
I
ClientSessionRequestOptions
No documentation available
I
I
I
I
Http2Session
> [!WARNING] Deno compatibility
> The following methods are non-functional stubs:
> - setLocalWindowSize
> - ping
> - localSettings
> - remoteSettings
> - settings
> - ref
> - unref
>
I
Http2Stream
> [!WARNING] Deno compatibility
> The following methods are non-functional stubs:
> - aborted
> - bufferSize
> - endAfterHeaders
> - id
> - pending
> - priority
> - rstCode
> - sentHeaders
> - sentInfoHeaders
> - sentTrailers
> - state
>
I
I
I
OutgoingHttpHeaders
No documentation available
- 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
- 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
- prgama
- 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
I
SecureClientSessionOptions
No documentation available
I
I
SecureServerSessionOptions
No documentation available
I
ServerHttp2Session
> [!WARNING] Deno compatibility
> All methods are non-functional stubs.
I
ServerHttp2Stream
No documentation available
I
ServerOptions
No documentation available
I
ServerSessionOptions
No documentation available
I
I
I
I
I
I
I
I
I
StreamState
No documentation available
N
constants
No documentation available
v
constants.DEFAULT_SETTINGS_ENABLE_PUSH
No documentation available
v
constants.DEFAULT_SETTINGS_HEADER_TABLE_SIZE
No documentation available
v
constants.DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE
No documentation available
v
constants.DEFAULT_SETTINGS_MAX_FRAME_SIZE
No documentation available
v
constants.HTTP2_HEADER_ACCEPT
No documentation available
v
constants.HTTP2_HEADER_ACCEPT_CHARSET
No documentation available
v
constants.HTTP2_HEADER_ACCEPT_ENCODING
No documentation available
v
constants.HTTP2_HEADER_ACCEPT_LANGUAGE
No documentation available
v
constants.HTTP2_HEADER_ACCEPT_RANGES
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS
No documentation available
v
constants.HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD
No documentation available
v
constants.HTTP2_HEADER_AGE
No documentation available
v
constants.HTTP2_HEADER_ALLOW
No documentation available
v
constants.HTTP2_HEADER_CACHE_CONTROL
No documentation available
v
constants.HTTP2_HEADER_CONNECTION
No documentation available
v
constants.HTTP2_HEADER_CONTENT_DISPOSITION
No documentation available
v
constants.HTTP2_HEADER_CONTENT_ENCODING
No documentation available
v
constants.HTTP2_HEADER_CONTENT_LANGUAGE
No documentation available
v
constants.HTTP2_HEADER_CONTENT_LENGTH
No documentation available
v
constants.HTTP2_HEADER_CONTENT_LOCATION
No documentation available
v
constants.HTTP2_HEADER_CONTENT_MD5
No documentation available
v
constants.HTTP2_HEADER_CONTENT_RANGE
No documentation available
v
constants.HTTP2_HEADER_CONTENT_TYPE
No documentation available
v
constants.HTTP2_HEADER_DATE
No documentation available
v
constants.HTTP2_HEADER_ETAG
No documentation available
v
constants.HTTP2_HEADER_EXPECT
No documentation available
v
constants.HTTP2_HEADER_EXPIRES
No documentation available
v
constants.HTTP2_HEADER_FROM
No documentation available
v
constants.HTTP2_HEADER_HOST
No documentation available
v
constants.HTTP2_HEADER_HTTP2_SETTINGS
No documentation available
v
constants.HTTP2_HEADER_IF_MATCH
No documentation available
v
constants.HTTP2_HEADER_IF_MODIFIED_SINCE
No documentation available
v
constants.HTTP2_HEADER_IF_NONE_MATCH
No documentation available
v
constants.HTTP2_HEADER_IF_RANGE
No documentation available
v
constants.HTTP2_HEADER_IF_UNMODIFIED_SINCE
No documentation available
v
constants.HTTP2_HEADER_KEEP_ALIVE
No documentation available
v
constants.HTTP2_HEADER_LAST_MODIFIED
No documentation available
v
constants.HTTP2_HEADER_LINK
No documentation available
v
constants.HTTP2_HEADER_LOCATION
No documentation available
v
constants.HTTP2_HEADER_MAX_FORWARDS
No documentation available
v
constants.HTTP2_HEADER_METHOD
No documentation available
v
constants.HTTP2_HEADER_PATH
No documentation available
v
constants.HTTP2_HEADER_PREFER
No documentation available
v
constants.HTTP2_HEADER_PROXY_AUTHENTICATE
No documentation available
v
constants.HTTP2_HEADER_PROXY_CONNECTION
No documentation available
v
constants.HTTP2_HEADER_RANGE
No documentation available
v
constants.HTTP2_HEADER_REFERER
No documentation available
v
constants.HTTP2_HEADER_REFRESH
No documentation available
v
constants.HTTP2_HEADER_RETRY_AFTER
No documentation available
v
constants.HTTP2_HEADER_SCHEME
No documentation available
v
constants.HTTP2_HEADER_SERVER
No documentation available
v
constants.HTTP2_HEADER_STATUS
No documentation available
v
constants.HTTP2_HEADER_STRICT_TRANSPORT_SECURITY
No documentation available
v
constants.HTTP2_HEADER_TE
No documentation available
v
constants.HTTP2_HEADER_TRANSFER_ENCODING
No documentation available
v
constants.HTTP2_HEADER_UPGRADE
No documentation available
v
constants.HTTP2_HEADER_USER_AGENT
No documentation available
v
constants.HTTP2_HEADER_VARY
No documentation available
v
constants.HTTP2_HEADER_VIA
No documentation available
v
constants.HTTP2_HEADER_WWW_AUTHENTICATE
No documentation available
v
constants.HTTP2_METHOD_ACL
No documentation available
v
constants.HTTP2_METHOD_BASELINE_CONTROL
No documentation available
v
constants.HTTP2_METHOD_BIND
No documentation available
v
constants.HTTP2_METHOD_CHECKIN
No documentation available
v
constants.HTTP2_METHOD_CHECKOUT
No documentation available
v
constants.HTTP2_METHOD_CONNECT
No documentation available
v
constants.HTTP2_METHOD_COPY
No documentation available
v
constants.HTTP2_METHOD_DELETE
No documentation available
v
constants.HTTP2_METHOD_GET
No documentation available
v
constants.HTTP2_METHOD_HEAD
No documentation available
v
constants.HTTP2_METHOD_LABEL
No documentation available
v
constants.HTTP2_METHOD_LINK
No documentation available
v
constants.HTTP2_METHOD_LOCK
No documentation available
v
constants.HTTP2_METHOD_MERGE
No documentation available
v
constants.HTTP2_METHOD_MKACTIVITY
No documentation available
v
constants.HTTP2_METHOD_MKCALENDAR
No documentation available
v
constants.HTTP2_METHOD_MKCOL
No documentation available
v
constants.HTTP2_METHOD_MKREDIRECTREF
No documentation available
v
constants.HTTP2_METHOD_MKWORKSPACE
No documentation available
v
constants.HTTP2_METHOD_MOVE
No documentation available
v
constants.HTTP2_METHOD_OPTIONS
No documentation available
v
constants.HTTP2_METHOD_ORDERPATCH
No documentation available
v
constants.HTTP2_METHOD_PATCH
No documentation available
v
constants.HTTP2_METHOD_POST
No documentation available
v
constants.HTTP2_METHOD_PRI
No documentation available
v
constants.HTTP2_METHOD_PROPFIND
No documentation available
v
constants.HTTP2_METHOD_PROPPATCH
No documentation available
v
constants.HTTP2_METHOD_PUT
No documentation available
v
constants.HTTP2_METHOD_REBIND
No documentation available
v
constants.HTTP2_METHOD_REPORT
No documentation available
v
constants.HTTP2_METHOD_SEARCH
No documentation available
v
constants.HTTP2_METHOD_TRACE
No documentation available
v
constants.HTTP2_METHOD_UNBIND
No documentation available
v
constants.HTTP2_METHOD_UNCHECKOUT
No documentation available
v
constants.HTTP2_METHOD_UNLINK
No documentation available
v
constants.HTTP2_METHOD_UNLOCK
No documentation available
v
constants.HTTP2_METHOD_UPDATE
No documentation available
v
constants.HTTP2_METHOD_UPDATEREDIRECTREF
No documentation available
v
constants.HTTP2_METHOD_VERSION_CONTROL
No documentation available
v
constants.HTTP_STATUS_ACCEPTED
No documentation available
v
constants.HTTP_STATUS_ALREADY_REPORTED
No documentation available
v
constants.HTTP_STATUS_BAD_GATEWAY
No documentation available
v
constants.HTTP_STATUS_BAD_REQUEST
No documentation available
v
constants.HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED
No documentation available
v
constants.HTTP_STATUS_CONFLICT
No documentation available
v
constants.HTTP_STATUS_CONTINUE
No documentation available
v
constants.HTTP_STATUS_CREATED
No documentation available
v
constants.HTTP_STATUS_EXPECTATION_FAILED
No documentation available
v
constants.HTTP_STATUS_FAILED_DEPENDENCY
No documentation available
v
constants.HTTP_STATUS_FORBIDDEN
No documentation available
v
constants.HTTP_STATUS_FOUND
No documentation available
v
constants.HTTP_STATUS_GATEWAY_TIMEOUT
No documentation available
v
constants.HTTP_STATUS_GONE
No documentation available
v
constants.HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED
No documentation available
v
constants.HTTP_STATUS_IM_USED
No documentation available
v
constants.HTTP_STATUS_INSUFFICIENT_STORAGE
No documentation available
v
constants.HTTP_STATUS_INTERNAL_SERVER_ERROR
No documentation available
v
constants.HTTP_STATUS_LENGTH_REQUIRED
No documentation available
v
constants.HTTP_STATUS_LOCKED
No documentation available
v
constants.HTTP_STATUS_LOOP_DETECTED
No documentation available
v
constants.HTTP_STATUS_METHOD_NOT_ALLOWED
No documentation available
v
constants.HTTP_STATUS_MISDIRECTED_REQUEST
No documentation available
v
constants.HTTP_STATUS_MOVED_PERMANENTLY
No documentation available
v
constants.HTTP_STATUS_MULTI_STATUS
No documentation available
v
constants.HTTP_STATUS_MULTIPLE_CHOICES
No documentation available
v
constants.HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED
No documentation available
v
constants.HTTP_STATUS_NO_CONTENT
No documentation available
v
constants.HTTP_STATUS_NOT_ACCEPTABLE
No documentation available
v
constants.HTTP_STATUS_NOT_EXTENDED
No documentation available
v
constants.HTTP_STATUS_NOT_FOUND
No documentation available
v
constants.HTTP_STATUS_NOT_IMPLEMENTED
No documentation available
v
constants.HTTP_STATUS_NOT_MODIFIED
No documentation available
v
constants.HTTP_STATUS_OK
No documentation available
v
constants.HTTP_STATUS_PARTIAL_CONTENT
No documentation available
v
constants.HTTP_STATUS_PAYLOAD_TOO_LARGE
No documentation available
v
constants.HTTP_STATUS_PAYMENT_REQUIRED
No documentation available
v
constants.HTTP_STATUS_PERMANENT_REDIRECT
No documentation available
v
constants.HTTP_STATUS_PRECONDITION_FAILED
No documentation available
v
constants.HTTP_STATUS_PRECONDITION_REQUIRED
No documentation available
v
constants.HTTP_STATUS_PROCESSING
No documentation available
v
constants.HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
No documentation available
v
constants.HTTP_STATUS_RANGE_NOT_SATISFIABLE
No documentation available
v
constants.HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE
No documentation available
v
constants.HTTP_STATUS_REQUEST_TIMEOUT
No documentation available
v
constants.HTTP_STATUS_RESET_CONTENT
No documentation available
v
constants.HTTP_STATUS_SEE_OTHER
No documentation available
v
constants.HTTP_STATUS_SWITCHING_PROTOCOLS
No documentation available
v
constants.HTTP_STATUS_TEAPOT
No documentation available
v
constants.HTTP_STATUS_TEMPORARY_REDIRECT
No documentation available
v
constants.HTTP_STATUS_TOO_MANY_REQUESTS
No documentation available
v
constants.HTTP_STATUS_UNORDERED_COLLECTION
No documentation available
v
constants.HTTP_STATUS_UNPROCESSABLE_ENTITY
No documentation available
v
constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
No documentation available
v
constants.HTTP_STATUS_UPGRADE_REQUIRED
No documentation available
v
constants.HTTP_STATUS_URI_TOO_LONG
No documentation available
v
constants.HTTP_STATUS_USE_PROXY
No documentation available
v
constants.HTTP_STATUS_VARIANT_ALSO_NEGOTIATES
No documentation available
v
constants.MAX_INITIAL_WINDOW_SIZE
No documentation available
v
constants.MAX_MAX_FRAME_SIZE
No documentation available
v
constants.MIN_MAX_FRAME_SIZE
No documentation available
v
constants.NGHTTP2_CANCEL
No documentation available
v
constants.NGHTTP2_COMPRESSION_ERROR
No documentation available
v
constants.NGHTTP2_CONNECT_ERROR
No documentation available
v
constants.NGHTTP2_DEFAULT_WEIGHT
No documentation available
v
constants.NGHTTP2_ENHANCE_YOUR_CALM
No documentation available
v
constants.NGHTTP2_ERR_FRAME_SIZE_ERROR
No documentation available
v
constants.NGHTTP2_FLAG_ACK
No documentation available
v
constants.NGHTTP2_FLAG_END_HEADERS
No documentation available
v
constants.NGHTTP2_FLAG_END_STREAM
No documentation available
v
constants.NGHTTP2_FLAG_NONE
No documentation available
v
constants.NGHTTP2_FLAG_PADDED
No documentation available
v
constants.NGHTTP2_FLAG_PRIORITY
No documentation available
v
constants.NGHTTP2_FLOW_CONTROL_ERROR
No documentation available
v
constants.NGHTTP2_FRAME_SIZE_ERROR
No documentation available
v
constants.NGHTTP2_HTTP_1_1_REQUIRED
No documentation available
v
constants.NGHTTP2_INADEQUATE_SECURITY
No documentation available
v
constants.NGHTTP2_INTERNAL_ERROR
No documentation available
v
constants.NGHTTP2_NO_ERROR
No documentation available
v
constants.NGHTTP2_PROTOCOL_ERROR
No documentation available
v
constants.NGHTTP2_REFUSED_STREAM
No documentation available
v
constants.NGHTTP2_SESSION_CLIENT
No documentation available
v
constants.NGHTTP2_SESSION_SERVER
No documentation available
v
constants.NGHTTP2_SETTINGS_ENABLE_PUSH
No documentation available
v
constants.NGHTTP2_SETTINGS_HEADER_TABLE_SIZE
No documentation available
v
constants.NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE
No documentation available
v
constants.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS
No documentation available
v
constants.NGHTTP2_SETTINGS_MAX_FRAME_SIZE
No documentation available
v
constants.NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE
No documentation available
v
constants.NGHTTP2_SETTINGS_TIMEOUT
No documentation available
v
constants.NGHTTP2_STREAM_CLOSED
No documentation available
v
constants.NGHTTP2_STREAM_STATE_CLOSED
No documentation available
v
constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL
No documentation available
v
constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE
No documentation available
v
constants.NGHTTP2_STREAM_STATE_IDLE
No documentation available
v
constants.NGHTTP2_STREAM_STATE_OPEN
No documentation available
v
constants.NGHTTP2_STREAM_STATE_RESERVED_LOCAL
No documentation available
v
constants.NGHTTP2_STREAM_STATE_RESERVED_REMOTE
No documentation available
v
constants.PADDING_STRATEGY_CALLBACK
No documentation available
v
constants.PADDING_STRATEGY_MAX
No documentation available
v
constants.PADDING_STRATEGY_NONE
No documentation available
v
sensitiveHeaders
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.