Skip to content

Http1ClientCodec

Defined in: packages/format-http/src/h1/http1-client-codec.ts:44

The client side of an HTTP/1.x connection: encodes requests, decodes responses.

The codec remembers the method of every request it encoded, in order, because a response cannot be framed without it — the response to HEAD declares a length it does not send, and a 2xx to CONNECT ends HTTP on the connection. Interim 1xx responses are decoded ahead of the final one they precede.

After a 101 or a 2xx to CONNECT the codec decodes nothing more: the connection carries another protocol from there on.

After a malformed or unsolicited response, decoding reports one error carrying an Http1MessageError, then discards everything: the connection must be dropped.

Decoding a head is O(n) time and memory in its size; the method queue is O(r) in the requests awaiting a response.

new Http1ClientCodec(options): Http1ClientCodec

Defined in: packages/format-http/src/h1/http1-client-codec.ts:53

Http1CodecOptions

Http1ClientCodec

decode(view): DecodeResult<Http1ClientInbound>

Defined in: packages/format-http/src/h1/http1-client-codec.ts:57

Attempt to decode one value from the front of view.

view is a window into the driver’s buffer and is invalidated as soon as this call returns. Copy anything retained in the returned value.

Uint8Array

DecodeResult<Http1ClientInbound>

Codec.decode


encode(value): readonly Uint8Array<ArrayBufferLike>[]

Defined in: packages/format-http/src/h1/http1-client-codec.ts:70

Encode a value into one or more output chunks.

Returning an array defers concatenation to a vectored write, so a length-prefixed protocol can emit [header, payload] without copying the payload.

Http1ClientOutbound

readonly Uint8Array<ArrayBufferLike>[]

Codec.encode


reset(): void

Defined in: packages/format-http/src/h1/http1-client-codec.ts:78

Discard accumulated decode state ahead of a protocol mode switch.

void

Codec.reset