Http1ServerCodec
Defined in: packages/format-http/src/h1/http1-server-codec.ts:48
The server side of an HTTP/1.x connection: decodes requests, encodes responses.
Decoding yields an Http1Request per request, whose body — when it has
one — follows as the value’s streamed body (length framing) or as
Http1Chunk values ended by Http1Trailers (chunked).
After a request asking to leave HTTP (an Upgrade field, or CONNECT),
decoding holds: the bytes that follow may already belong to the next
protocol. Call release when declining the switch to resume.
After a malformed request, decoding reports one error carrying an
Http1MessageError, then discards everything: the server should answer
with the error’s status and close the connection.
Encoding writes an Http1ResponseHead, one Http1ChunkData, or the last chunk and trailers (Http1Trailers), as buffers ready for one vectored write. The caller chooses the framing through the fields it sets.
Decoding a head is O(n) time and memory in its size.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Http1ServerCodec(
options):Http1ServerCodec
Defined in: packages/format-http/src/h1/http1-server-codec.ts:57
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Http1ServerCodec
Methods
Section titled “Methods”decode()
Section titled “decode()”decode(
view):DecodeResult<Http1ServerInbound>
Defined in: packages/format-http/src/h1/http1-server-codec.ts:61
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.
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”DecodeResult<Http1ServerInbound>
Implementation of
Section titled “Implementation of”Codec.decode
encode()
Section titled “encode()”encode(
value): readonlyUint8Array<ArrayBufferLike>[]
Defined in: packages/format-http/src/h1/http1-server-codec.ts:79
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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”readonly Uint8Array<ArrayBufferLike>[]
Implementation of
Section titled “Implementation of”Codec.encode
release()
Section titled “release()”release():
void
Defined in: packages/format-http/src/h1/http1-server-codec.ts:84
Resume decoding after declining the protocol switch a request asked for.
Returns
Section titled “Returns”void
reset()
Section titled “reset()”reset():
void
Defined in: packages/format-http/src/h1/http1-server-codec.ts:91
Discard accumulated decode state ahead of a protocol mode switch.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Codec.reset