abla/http/h2

Generated from source.

Import with import "abla/http/h2".

Source: abla/http/h2/entry.ab

H2_NO_ERROR (val)

val H2_NO_ERROR

Identifies an HTTP/2 shutdown without a protocol error.

H2_PROTOCOL_ERROR (val)

val H2_PROTOCOL_ERROR

Identifies a violation of the HTTP/2 protocol.

H2_INTERNAL_ERROR (val)

val H2_INTERNAL_ERROR

Identifies an internal HTTP/2 endpoint error.

H2_FLOW_CONTROL_ERROR (val)

val H2_FLOW_CONTROL_ERROR

Identifies a violation of HTTP/2 flow control.

H2_SETTINGS_TIMEOUT (val)

val H2_SETTINGS_TIMEOUT

Identifies a missing acknowledgement of local settings.

H2_STREAM_CLOSED (val)

val H2_STREAM_CLOSED

Identifies a frame received on a closed stream.

H2_FRAME_SIZE_ERROR (val)

val H2_FRAME_SIZE_ERROR

Identifies a frame length that is invalid for its type or current limit.

H2_REFUSED_STREAM (val)

val H2_REFUSED_STREAM

Identifies a stream refused before the peer processed it.

H2_CANCEL (val)

val H2_CANCEL

Identifies cancellation of a stream that is no longer needed.

H2_COMPRESSION_ERROR (val)

val H2_COMPRESSION_ERROR

Identifies an error processing the compressed header block.

H2_ENHANCE_YOUR_CALM (val)

val H2_ENHANCE_YOUR_CALM

Identifies a peer that exceeds a connection resource or activity limit.

H2_EVENT_HEADERS (val)

val H2_EVENT_HEADERS

Identifies the final response headers and status.

H2_EVENT_DATA (val)

val H2_EVENT_DATA

Identifies response body data delivered directly in an event.

H2_EVENT_END (val)

val H2_EVENT_END

Identifies successful completion of a response stream.

H2_EVENT_RESET (val)

val H2_EVENT_RESET

Identifies a failed stream and carries its reason and retry status.

H2_EVENT_GOAWAY (val)

val H2_EVENT_GOAWAY

Identifies a received GOAWAY and carries the last stream the peer processed.

H2_EVENT_CLOSED (val)

val H2_EVENT_CLOSED

Identifies a connection closure event.

H2_EVENT_TRAILERS (val)

val H2_EVENT_TRAILERS

Identifies trailing response fields received before the end of the stream.

H2_EVENT_READABLE (val)

val H2_EVENT_READABLE

Identifies response body bytes ready for a streaming reader.

H2_EVENT_WRITABLE (val)

val H2_EVENT_WRITABLE

Identifies available buffer space after a streaming request write was partial.

H2_MAX_FRAME_PAYLOAD (val)

val H2_MAX_FRAME_PAYLOAD

Limits that are not options: a caller cannot weaken them by accident.

H2_MAX_BLOCK_BYTES (val)

val H2_MAX_BLOCK_BYTES

Caps the compressed bytes accepted in one header block.

H2_MAX_CONTINUATIONS (val)

val H2_MAX_CONTINUATIONS

Caps the frame count accepted for one continued header block.

H2_MAX_FIELD_BYTES (val)

val H2_MAX_FIELD_BYTES

Caps the byte length of one decoded header field.

H2_MAX_FIELDS (val)

val H2_MAX_FIELDS

Caps the number of fields in a decoded header list.

H2_MAX_QUIET_FRAMES (val)

val H2_MAX_QUIET_FRAMES

Caps consecutive control frames that make no stream progress.

H2_MAX_CONTROL_PER_SECOND (val)

val H2_MAX_CONTROL_PER_SECOND

Caps control frames accepted in one second.

H2_MAX_PENDING_ACKS (val)

val H2_MAX_PENDING_ACKS

Caps acknowledgements waiting to be sent to the peer.

H2_OUTPUT_CAP (val)

val H2_OUTPUT_CAP

Caps the output buffered by the connection.

H2_INITIAL_WINDOW (val)

val H2_INITIAL_WINDOW

Sets the local initial stream receive window.

H2_STREAM_BODY_CAP (val)

val H2_STREAM_BODY_CAP

The request bytes a streaming request holds unsent (writeBody takes in no more): one stream window.

H2_CONNECTION_WINDOW (val)

val H2_CONNECTION_WINDOW

Sets the local connection receive window.

H2_MAX_WINDOW (val)

val H2_MAX_WINDOW

Holds the largest flow-control window allowed by HTTP/2.

H2_MAX_RESET_REMEMBERED (val)

val H2_MAX_RESET_REMEMBERED

Caps the recently reset stream IDs retained by the connection.

H2_PREFACE (val)

val H2_PREFACE

Holds the bytes sent before the initial client SETTINGS frame.

H2Event (class)

class H2Event(val kind: int, val stream: int, val status: int = 0, val headers: array<HpackField> = [], val data: string = "", val code: int = 0, val error: string = "", val retry: bool = false)

Something that happened on the connection. kind is one of the H2_EVENT_ values: HEADERS: status and headers (final response headers, lower case, no pseudo-headers); DATA: data; END: the stream finished well; RESET: the stream failed (code, error; retry says the server did not process it: REFUSED_STREAM, or beyond a GOAWAY's last id); TRAILERS: headers (the trailer fields, before END); READABLE / WRITABLE (streaming requests only, requestStream): bytes wait in the stream's inbox for takeData (sent when the inbox was empty); writeBody has room again after it took in less than it was given; GOAWAY: code and stream (the last stream the peer processed); CLOSED: the connection ended (error, code).

H2Stream (class)

class H2Stream(val id: int, var state: int = 0, var sendWindow: int = 0, var recvWindow: int = 0, var owed: int = 0, var body: string = "", var bodyPosition: int = 0,
    var localDone: bool = false, var status: int = -1, var contentLength: int = -1, var received: int = 0, var head: bool = false, var sawFinal: bool = false,
    // A streaming request (requestStream): the response body waits in `inbox` for takeData (the window is credited as it is taken), the request body is written with
    // writeBody until finishBody (`bodyFinished`); `ended` is the response's END_STREAM, its END event waits for the inbox to be empty; `blocked` is a writeBody that took less than it was given.
    var streaming: bool = false, var inbox: string = "", var bodyFinished: bool = true, var ended: bool = false, var blocked: bool = false)

Tracks the windows, body buffers and lifecycle of one HTTP/2 stream.

H2Client (class)

class H2Client(
    var streams: array<H2Stream> = [],
    var resetIds: array<int> = [],
    var decoder: HpackDecoder,
    var encoder: HpackEncoder,
    var events: array<H2Event> = [],
    var output: ByteBuffer,
    var outputBytes: int = 0,
    var input: string = "",
    var nextStreamId: int = 1,
    var peerSeen: bool = false,
    var draining: bool = false,
    var closed: bool = false,
    var connectionSend: int = 65535,
    var connectionReceive: int = 0,
    var connectionOwed: int = 0,
    var peerInitialWindow: int = 65535,
    var peerMaxFrame: int = 16384,
    var peerMaxConcurrent: int = 2147483647,
    var maxStreams: int = 100,
    var maximumResponseBytes: int = 16777216,
    var blockStream: int = 0,
    var blockFragments: string = "",
    var blockBytes: int = 0,
    var blockCount: int = 0,
    var blockEndStream: bool = false,
    var quiet: int = 0,
    var controlWindowStart: int = 0,
    var controlInWindow: int = 0,
    var pendingAcks: int = 0,
    var settingsAckDeadline: int = -1,
    var pingDeadline: int = -1,
    var roundRobin: int = 0,
    var lastPeerStream: int = 0)

Holds the HTTP/2 client connection's stream, compression and flow-control state.

h2Be16 (fun)

fun h2Be16(value: int): string

Returns the low 16 bits of the input as two big-endian bytes.

h2Be32 (fun)

fun h2Be32(value: int): string

Returns the low 32 bits of the input as four big-endian bytes.

h2Frame (fun)

fun h2Frame(kind: int, flags: int, stream: int, payload: string): string

Returns the encoded frame header and payload, with the reserved stream ID bit cleared.

h2Read32 (fun)

fun h2Read32(data: string, at: int): int

Returns an unsigned big-endian 32-bit integer, requiring four readable bytes from the given offset.

h2Setting (fun)

fun h2Setting(id: int, value: int): string

Returns the six wire bytes of one SETTINGS identifier and value.

h2ClientNew (fun)

fun h2ClientNew(maximumStreams: int = 100, maximumResponseBytes: int = 16777216, maximumHeaderListBytes: int = 65536, neverIndex: array<string> = []): H2Client

A connection with its preface and our SETTINGS queued (nothing is written until takeOutput). maximumStreams caps concurrent streams, maximumResponseBytes the body of one response, maximumHeaderListBytes a decoded header list, neverIndex names HPACK never indexes.

H2Client.takeOutput (extension fun)

fun H2Client.takeOutput(): string

The bytes to write to the peer now.

H2Client.wantsWrite (extension fun)

fun H2Client.wantsWrite(): bool

True when there is output to write (including body held back by the output cap).

H2Client.takeEvents (extension fun)

fun H2Client.takeEvents(): array<H2Event>

The events since the last call.

H2Client.isClosed (extension fun)

fun H2Client.isClosed(): bool

Returns whether the connection has closed.

H2Client.isDraining (extension fun)

fun H2Client.isDraining(): bool

Returns whether the connection is draining or has closed.

H2Client.openStreams (extension fun)

fun H2Client.openStreams(): int

Returns the number of streams still tracked on the connection.

H2Client.hasRoom (extension fun)

fun H2Client.hasRoom(): bool

True when a new request can start on this connection now.

h2CodeName (fun)

fun h2CodeName(code: int): string

Returns the name of a recognized HTTP/2 error code or a string containing the unknown numeric code.

H2Client.shutdown (extension fun)

fun H2Client.shutdown(): void

A clean end of an idle connection: GOAWAY(NO_ERROR). Streams still open fail as if the connection broke.

H2Client.broken (extension fun)

fun H2Client.broken(reason: string): void

The connection broke from outside (the socket ended or failed): every stream fails, nothing is queued.

H2Client.cancel (extension fun)

fun H2Client.cancel(id: int): void

The caller gives up on a stream (a deadline, an oversize response): RST_STREAM(CANCEL); no event.

h2Forbidden (fun)

fun h2Forbidden(name: string): bool

---- requests ----

H2Client.request (extension fun)

fun H2Client.request(method: string, scheme: string, authority: string, path: string, headers: array<HpackField>, body: string): int

Starts a request: HEADERS (and DATA as the windows allow). Returns the stream id, -1 when the connection cannot take it (draining, closed, no room): the caller uses another connection. headers are the caller's (any case); host, connection, keep-alive, proxy-connection, transfer-encoding and upgrade are dropped (te only as trailers), and content-length is added for a body unless given. -1 too, with nothing sent, for parts that could not be sent as they are: a method that is not a token, a path or authority with a space or control byte, a header name that is not a token or a value with NUL, CR or LF.

H2Client.requestStream (extension fun)

fun H2Client.requestStream(method: string, scheme: string, authority: string, path: string, headers: array<HpackField>, length: int = -1): int

A request whose body and response are streamed: the response body is read with takeData (events HEADERS, READABLE, TRAILERS, END, RESET), the request body written with writeBody and ended with finishBody. length is the request body's size when known (it is sent as content-length; 0 ends the stream at once), -1 when not. Returns the stream id, -1 when the connection cannot take it.

H2Client.writeBody (extension fun)

fun H2Client.writeBody(id: int, chunk: string): int

Writes request body bytes of a streaming request (requestStream): returns how many were taken (the first taken bytes of chunk), 0 when the stream already holds a window's worth of unsent bytes (a WRITABLE event follows when there is room again), -1 when the stream is gone, finished or not a streaming one. The sent bytes go out as the peer's windows allow.

H2Client.finishBody (extension fun)

fun H2Client.finishBody(id: int): void

The request body of a streaming request is complete: the last DATA frame carries END_STREAM (an empty one when everything was sent already).

H2Client.takeData (extension fun)

fun H2Client.takeData(id: int, maximum: int): string

Takes up to maximum bytes of the response body of a streaming request. Taking is what gives the peer credit again (a WINDOW_UPDATE once half a window was taken): a caller that does not take stalls the peer after one stream window. Call it until it returns "" after a READABLE event; the END event comes once the last byte was taken.

H2Client.pendingData (extension fun)

fun H2Client.pendingData(id: int): int

The bytes a streaming request's response holds that takeData has not taken.

H2Client.ping (extension fun)

fun H2Client.ping(now: int): void

Sends a PING; the ACK must come within five seconds (tick).

H2Client.pingOutstanding (extension fun)

fun H2Client.pingOutstanding(): bool

Returns whether the connection is waiting for a PING acknowledgement.

H2Client.tick (extension fun)

fun H2Client.tick(now: int): void

Timeouts: our SETTINGS unacknowledged for 10 s, a PING unanswered for 5 s.

H2Client.feed (extension fun)

fun H2Client.feed(data: string, now: int): void

Bytes from the peer. Complete frames are processed; a partial one waits for the next call.

h2HasUpper (fun)

fun h2HasUpper(name: string): bool

Returns whether the header name contains an ASCII uppercase letter.

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