Http2ClientConnection
Defined in: packages/net-http/src/h2/http2-client-connection.ts:71
Sends HTTP/2 requests over one connection, each on its own stream,
concurrently up to the server’s SETTINGS_MAX_CONCURRENT_STREAMS; a request
beyond it waits for a stream to close.
Aborting a request resets its stream only, and so does cancelling its
response body. After the server’s GOAWAY, requests it did not process fail
with HttpConnectionError and may be retried on a new connection.
Prefer HttpAgent, which opens and reuses connections per origin and picks
HTTP/2 through ALPN; this class is the per-connection piece.
Extends
Section titled “Extends”EventDispatcherMapBase<Http2ClientConnectionEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Http2ClientConnection(
options):Http2ClientConnection
Defined in: packages/net-http/src/h2/http2-client-connection.ts:77
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Http2ClientConnection
Overrides
Section titled “Overrides”EventDispatcherMapBase<Http2ClientConnectionEvents>.constructor
Accessors
Section titled “Accessors”activeStreams
Section titled “activeStreams”Get Signature
Section titled “Get Signature”get activeStreams():
number
Defined in: packages/net-http/src/h2/http2-client-connection.ts:115
Streams currently open.
Returns
Section titled “Returns”number
available
Section titled “available”Get Signature
Section titled “Get Signature”get available():
boolean
Defined in: packages/net-http/src/h2/http2-client-connection.ts:110
Whether a request would get a stream now, without waiting.
Returns
Section titled “Returns”boolean
reusable
Section titled “reusable”Get Signature
Section titled “Get Signature”get reusable():
boolean
Defined in: packages/net-http/src/h2/http2-client-connection.ts:105
Whether the connection may carry new requests at all.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<void>
Defined in: packages/net-http/src/h2/http2-client-connection.ts:214
Send GOAWAY, let the open streams finish, then close.
Returns
Section titled “Returns”Promise<void>
Resolves once the connection closed.
destroy()
Section titled “destroy()”destroy(
error?):void
Defined in: packages/net-http/src/h2/http2-client-connection.ts:220
Close at once, failing every request in progress.
Parameters
Section titled “Parameters”error?
Section titled “error?”unknown
Returns
Section titled “Returns”void
extendedConnectEnabled()
Section titled “extendedConnectEnabled()”extendedConnectEnabled():
Promise<boolean>
Defined in: packages/net-http/src/h2/http2-client-connection.ts:125
Whether the server accepts extended CONNECT (request.protocol), once
its SETTINGS arrived.
Returns
Section titled “Returns”Promise<boolean>
Throws
Section titled “Throws”When the connection closed first.
isSubscribed()
Section titled “isSubscribed()”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.
Type Parameters
Section titled “Type Parameters”K extends keyof Http2ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<Http2ClientConnectionEvents[K]>
The callback to check.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.isSubscribed
request()
Section titled “request()”request(
request,options?):Promise<HttpIncomingResponse>
Defined in: packages/net-http/src/h2/http2-client-connection.ts:139
Send a request on a new stream and resolve with its response head; the body follows as the response’s stream.
Parameters
Section titled “Parameters”request
Section titled “request”options?
Section titled “options?”Returns
Section titled “Returns”Promise<HttpIncomingResponse>
Throws
Section titled “Throws”When the connection is closing or closed, or
the server refused the stream (GOAWAY, REFUSED_STREAM).
Throws
Section titled “Throws”When request.protocol is set with a method other than
CONNECT, or the server did not enable extended CONNECT.
subscribe()
Section titled “subscribe()”subscribe<
K>(event,listener,options?):Callable|null
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23
Type Parameters
Section titled “Type Parameters”K extends keyof Http2ClientConnectionEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<Http2ClientConnectionEvents[K]>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Returns
Section titled “Returns”Callable | null
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.subscribe
unsubscribe()
Section titled “unsubscribe()”unsubscribe<
K>(event,listener):void
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31
Unsubscribe a callback from a specific event.
Type Parameters
Section titled “Type Parameters”K extends keyof Http2ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<Http2ClientConnectionEvents[K]>
The callback to remove.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.unsubscribe
wait()
Section titled “wait()”wait<
K>(event,options?):Promise<Http2ClientConnectionEvents[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.
Type Parameters
Section titled “Type Parameters”K extends keyof Http2ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name to wait for.
options?
Section titled “options?”EventDispatcherWaitOptions<Http2ClientConnectionEvents[K]>
Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<Http2ClientConnectionEvents[K]>
A promise that resolves with the event arguments as an array.
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.wait