Skip to content

Http2ServerConnection

Defined in: packages/net-http/src/h2/http2-server-connection.ts:88

Serves HTTP/2 on one connection: every stream the client opens is a request, handled concurrently up to limits.maxConcurrentStreams.

Request bodies are read under flow control — a slow handler holds back only its own stream — and a response sent before its request body was read resets the stream with NO_ERROR, which tells the client to stop sending (RFC 9113 §8.1). Aborting a handler’s signal, or the client resetting its stream, affects that stream only.

Extended CONNECT (RFC 8441) is advertised, so a handler can accept a WebSocket with acceptWebSocket: a 2xx with a tunnel hands the stream over as a Transport.

Use HttpServer to accept connections; this class is the per-connection piece, for custom servers and tests.

new Http2ServerConnection(options): Http2ServerConnection

Defined in: packages/net-http/src/h2/http2-server-connection.ts:93

Http2ServerConnectionOptions

Http2ServerConnection

EventDispatcherMapBase<Http2ServerConnectionEvents>.constructor

get idle(): boolean

Defined in: packages/net-http/src/h2/http2-server-connection.ts:134

Whether no stream is open.

boolean

close(): Promise<void>

Defined in: packages/net-http/src/h2/http2-server-connection.ts:143

Send GOAWAY, let the open streams finish, then close.

Promise<void>

Resolves once the connection closed.


destroy(error?): void

Defined in: packages/net-http/src/h2/http2-server-connection.ts:149

Close at once, resetting every open stream.

unknown

void


isSubscribed<K>(event, listener): boolean

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38

Check if a callback is subscribed to a specific event.

K extends keyof Http2ServerConnectionEvents

K

The event name.

Callable<Http2ServerConnectionEvents[K]>

The callback to check.

boolean

EventDispatcherMapBase.isSubscribed


subscribe<K>(event, listener, options?): Callable | null

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23

K extends keyof Http2ServerConnectionEvents

K

Callable<Http2ServerConnectionEvents[K]>

EventDispatcherSubscribeOptions

Callable | null

EventDispatcherMapBase.subscribe


unsubscribe<K>(event, listener): void

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31

Unsubscribe a callback from a specific event.

K extends keyof Http2ServerConnectionEvents

K

The event name.

Callable<Http2ServerConnectionEvents[K]>

The callback to remove.

void

EventDispatcherMapBase.unsubscribe


wait<K>(event, options?): Promise<Http2ServerConnectionEvents[K]>

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:45

Wait for the next occurrence of a specific event, optionally matching a predicate.

This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.

K extends keyof Http2ServerConnectionEvents

K

The event name to wait for.

EventDispatcherWaitOptions<Http2ServerConnectionEvents[K]>

Optional settings including predicate and abort signal.

Promise<Http2ServerConnectionEvents[K]>

A promise that resolves with the event arguments as an array.

EventDispatcherMapBase.wait