abla/http/stream

Generated from source.

Import with import "abla/http/stream".

Source: abla/http/stream/entry.ab

HttpChunkDecode (class)

class HttpChunkDecode(
    val body: string,
    val consumed: int,
    val complete: bool,
    val error: string,
    // For incomplete input: the offset of the first chunk element (a size line with its data, or the last chunk and its trailers) that
    // is not complete. `body` holds everything before it, so a caller may drop those bytes and decode the rest when more arrives.
    val resume: int = 0,
    // For input that ends inside a chunk's data: the input size at which that chunk is complete (zero otherwise).
    val need: int = 0
)

Carries decoded bytes, the consumed offset, completion status and any framing error.

ServerSentEvent (class)

class ServerSentEvent(
    val data: string,
    val event: string,
    val id: string,
    val retryMilliseconds: int
)

Stores the data, optional event name and ID, and retry interval of an SSE message.

httpHeaderTokenContains (fun)

fun httpHeaderTokenContains(value: string, wanted: string): bool

Checks for a case-insensitive token in a comma-separated header, ignoring parameters after the token.

httpRequestKeepAlive (fun)

fun httpRequestKeepAlive(request: HttpRequest): bool

Reports whether the request omits the close token in its Connection header.

httpChunkEncode (fun)

fun httpChunkEncode(payload: string): string

Frames a payload with its hexadecimal length and CRLF delimiters.

httpChunkEnd (fun)

fun httpChunkEnd(trailers: array<HttpHeader> = []): string

Renders the terminating zero-length chunk and optional trailer fields.

httpDecodeChunked (fun)

fun httpDecodeChunked(
    input: string,
    maximumBody: int = 1048576
): HttpChunkDecode

Decodes a bounded chunked body, distinguishing incomplete input from invalid framing or lengths.

httpChunkedResponse (fun)

fun httpChunkedResponse(
    chunks: array<string>,
    status: int = 200,
    headers: array<HttpHeader> = []
): string

Renders an HTTP/1.1 response with chunked framing, the given headers and a terminating chunk.

httpGzipResponse (fun)

fun httpGzipResponse(
    request: HttpRequest,
    response: HttpResponse,
    minimumBytes: int = 256
): HttpResponse

Returns a gzip-encoded response only when the client accepts gzip and compression shrinks an eligible body.

serverSentEvent (fun)

fun serverSentEvent(
    data: string,
    event: string = "",
    id: string = "",
    retryMilliseconds: int = 0
): ServerSentEvent

Creates an SSE message with optional event name, ID and retry interval.

ServerSentEvent.encode (extension fun)

fun ServerSentEvent.encode(): string

Renders the event as newline-delimited SSE fields followed by a blank line.

sseResponseHead (fun)

fun sseResponseHead(): string

Renders the headers for a successful chunked SSE response.

sseChunk (fun)

fun sseChunk(event: ServerSentEvent): string

Encodes one SSE event as a single HTTP chunk.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.