class Http1Encoder
source · line 42public class Http1Encoder public constructor(
/**
* The fixed client/server role of this codec.
*/
public val role: HttpRole
) : Closeable
- Supertype
Closeable - Inherited
fun dispose(): Unit· Closeable
An HTTP/1 encoder with explicit message begin, body, and finish. It produces framing bytes without performing transport I/O; close does not finish a message.
property isSwitched
source · line 71public val isSwitched: Boolean
get: public read-only
Whether the encoded response transferred the connection to another protocol.
getter get
source · line 71get(): Boolean
constructor constructor
source · line 42constructor(public val role: HttpRole)
parameter role
source · line 46public val role: HttpRole
function beginRequest
source · line 113public fun beginRequest(head: HttpRequestHead, body: Http1BodyFraming = Http1BodyFraming.Empty): Array<Byte>
Validates and encodes a client request head, selecting explicit body framing. Every successful begin requires finish.
parameter body
source · line 115body: Http1BodyFraming = Http1BodyFraming.Empty
parameter head
source · line 114head: HttpRequestHead
property isMessageOpen
source · line 63public val isMessageOpen: Boolean
get: public read-only
Whether begin has started a message that still requires finish.
getter get
source · line 63get(): Boolean
property role
source · line 46public val role: HttpRole
get: public read-only
The fixed client/server role of this codec.
property isClosed
source · line 59public val isClosed: Boolean
get: public read-only
Whether its state has been released.
getter get
source · line 59get(): Boolean
function prepareBody
source · line 218public fun prepareBody(count: Long): Http1BodyChunk
Accepts a body length and returns only its surrounding framing. The caller emits prefix, its original payload, then suffix; a failed transmission must not retry this accepted chunk.
parameter count
source · line 218count: Long
function close
source · line 286public override fun close(): Unit
- Overrides
close
Releases codec state without sending, finishing, or closing a transport.
function finish
source · line 261public fun finish(trailers: List<HttpField> = ArrayList<HttpField>()): Array<Byte>
Completes the current message and returns final framing bytes; trailers require chunked framing and fixed-length bodies must be complete.
parameter trailers
source · line 261trailers: List<HttpField> = ArrayList<HttpField>()
function writeBody
source · line 228public fun writeBody(buffer: NativeByteBuffer, count: Long = buffer.readableBytes): Array<
Byte
>
Consumes body bytes and returns their complete framed representation for in-memory use. Rejected or failed encoding leaves the input position and declared length unchanged.
parameter buffer
source · line 228buffer: NativeByteBuffer
parameter count
source · line 228count: Long = buffer.readableBytes
function beginResponse
source · line 141public fun beginResponse(head: HttpResponseHead, requestMethod: List<Byte>, body: Http1BodyFraming = Http1BodyFraming.Empty): Array<Byte>
Encodes a server response using the exact originating method to determine body and switching rules. Returned bytes are immutable and remain valid across later messages and close.
parameter requestMethod
source · line 143requestMethod: List<Byte>
parameter body
source · line 144body: Http1BodyFraming = Http1BodyFraming.Empty
parameter head
source · line 142head: HttpResponseHead
property mustClose
source · line 67public val mustClose: Boolean
get: public read-only
Whether the caller must close the transport after the encoded message.
getter get
source · line 67get(): Boolean