Http1ClientConnection
Defined in: packages/net-http/src/h1/http1-client-connection.ts:98
Sends HTTP/1.1 requests over one connection, one exchange at a time.
An exchange lasts until its request was sent and its response body read to
the end; only then does the connection emit idle and accept the next
request. A response body that is cancelled, or a response that does not allow
keep-alive, closes the connection instead.
Prefer HttpAgent, which opens, pools and reuses connections per origin; this class is the per-connection piece.
Extends
Section titled “Extends”EventDispatcherMapBase<Http1ClientConnectionEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Http1ClientConnection(
options):Http1ClientConnection
Defined in: packages/net-http/src/h1/http1-client-connection.ts:109
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Http1ClientConnection
Overrides
Section titled “Overrides”EventDispatcherMapBase<Http1ClientConnectionEvents>.constructor
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get busy():
boolean
Defined in: packages/net-http/src/h1/http1-client-connection.ts:128
Whether an exchange is in progress.
Returns
Section titled “Returns”boolean
reusable
Section titled “reusable”Get Signature
Section titled “Get Signature”get reusable():
boolean
Defined in: packages/net-http/src/h1/http1-client-connection.ts:133
Whether the connection can carry another request once idle.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<void>
Defined in: packages/net-http/src/h1/http1-client-connection.ts:217
Close once the exchange in progress, if any, completed.
Returns
Section titled “Returns”Promise<void>
Resolves once the connection closed.
destroy()
Section titled “destroy()”destroy(
error?):void
Defined in: packages/net-http/src/h1/http1-client-connection.ts:230
Close at once, failing the exchange in progress.
Parameters
Section titled “Parameters”error?
Section titled “error?”unknown
Returns
Section titled “Returns”void
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 Http1ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<Http1ClientConnectionEvents[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/h1/http1-client-connection.ts:146
Send a request 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 busy or closed, or closes before the response head arrived.
Throws
Section titled “Throws”When request.protocol is set with a method other than
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 Http1ClientConnectionEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<Http1ClientConnectionEvents[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 Http1ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<Http1ClientConnectionEvents[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<Http1ClientConnectionEvents[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 Http1ClientConnectionEvents
Parameters
Section titled “Parameters”K
The event name to wait for.
options?
Section titled “options?”EventDispatcherWaitOptions<Http1ClientConnectionEvents[K]>
Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<Http1ClientConnectionEvents[K]>
A promise that resolves with the event arguments as an array.
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.wait