Skip to content

Http1ServerConnection

Defined in: packages/net-http/src/h1/http1-server-connection.ts:91

Serves HTTP/1.x on one connection: decodes requests in order, runs the handler for each, writes its response, keeps the connection alive between requests when both sides allow it, and hands it over on an accepted Upgrade or CONNECT.

Requests are handled one at a time even when pipelined, since HTTP/1.1 responses must leave in request order. Receiving stops while a request is handled, so pipelined requests cannot queue beyond what one read delivered.

A response sent before its request body was read to the end closes the connection afterwards rather than draining an unbounded body.

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

new Http1ServerConnection(options): Http1ServerConnection

Defined in: packages/net-http/src/h1/http1-server-connection.ts:104

Http1ServerConnectionOptions

Http1ServerConnection

EventDispatcherMapBase<Http1ServerConnectionEvents>.constructor

get idle(): boolean

Defined in: packages/net-http/src/h1/http1-server-connection.ts:129

Whether no request is being handled or waiting to be.

boolean

close(): Promise<void>

Defined in: packages/net-http/src/h1/http1-server-connection.ts:139

Finish the request being handled, if any, then close. Requests not yet started are dropped.

Promise<void>

Resolves once the connection closed.


destroy(error?): void

Defined in: packages/net-http/src/h1/http1-server-connection.ts:148

Close at once, aborting the request being handled.

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 Http1ServerConnectionEvents

K

The event name.

Callable<Http1ServerConnectionEvents[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 Http1ServerConnectionEvents

K

Callable<Http1ServerConnectionEvents[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 Http1ServerConnectionEvents

K

The event name.

Callable<Http1ServerConnectionEvents[K]>

The callback to remove.

void

EventDispatcherMapBase.unsubscribe


wait<K>(event, options?): Promise<Http1ServerConnectionEvents[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 Http1ServerConnectionEvents

K

The event name to wait for.

EventDispatcherWaitOptions<Http1ServerConnectionEvents[K]>

Optional settings including predicate and abort signal.

Promise<Http1ServerConnectionEvents[K]>

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

EventDispatcherMapBase.wait