# std::http API Reference

Public declarations reachable through the documented package entry points. Signatures follow the source snapshot; consult the module guide for support and qualification boundaries.


## Application entry points

Choose [client exchanges](client.md), [direct Server callbacks](server.md), or [Fiber routing](fiber.md) before consulting signatures. [HTTP/2](h2.md) and [WebSocket](ws.md) have separate protocol and qualification boundaries. Names declared `export` in an internal module are not necessarily re-exported from `"http"` or `"http/fiber"`.


## Re-exports from other packages

- [`WsFrame`](../net_reference.md#WsFrame) from `"http/ws"`.

<a id="HTTP_V1"></a>

### HTTP_V1

Import: `"http/fiber"`.

```vex
export const HTTP_V1: u32=1 as u32;
```

<a id="HTTP_V2"></a>

### HTTP_V2

Import: `"http/fiber"`.

```vex
export const HTTP_V2: u32=1 as u32 << 1;
```

<a id="WEBSOCKET"></a>

### WEBSOCKET

Import: `"http/fiber"`.

```vex
export const WEBSOCKET: u32=1 as u32 << 2;
```

<a id="ASYNC_ROUTES"></a>

### ASYNC_ROUTES

Import: `"http/fiber"`.

```vex
export const ASYNC_ROUTES: u32=1 as u32 << 3;
```

<a id="REQUEST_STREAMING"></a>

### REQUEST_STREAMING

Import: `"http/fiber"`.

```vex
export const REQUEST_STREAMING: u32=1 as u32 << 4;
```

<a id="RESPONSE_STREAMING"></a>

### RESPONSE_STREAMING

Import: `"http/fiber"`.

```vex
export const RESPONSE_STREAMING: u32=1 as u32 << 5;
```

<a id="HTTP_FULL"></a>

### HTTP_FULL

Import: `"http/fiber"`.

```vex
export const HTTP_FULL: u32=HTTP_V1 | HTTP_V2 | WEBSOCKET |
    ASYNC_ROUTES | REQUEST_STREAMING | RESPONSE_STREAMING;
```

<a id="FRAME_DATA"></a>

### FRAME_DATA

Import: `"http/parser"`.

```vex
export const FRAME_DATA: u8=0x0;
```

<a id="FRAME_HEADERS"></a>

### FRAME_HEADERS

Import: `"http/parser"`.

```vex
export const FRAME_HEADERS: u8=0x1;
```

<a id="FRAME_PRIORITY"></a>

### FRAME_PRIORITY

Import: `"http/parser"`.

```vex
export const FRAME_PRIORITY: u8=0x2;
```

<a id="FRAME_RST_STREAM"></a>

### FRAME_RST_STREAM

Import: `"http/parser"`.

```vex
export const FRAME_RST_STREAM: u8=0x3;
```

<a id="FRAME_SETTINGS"></a>

### FRAME_SETTINGS

Import: `"http/parser"`.

```vex
export const FRAME_SETTINGS: u8=0x4;
```

<a id="FRAME_PUSH_PROMISE"></a>

### FRAME_PUSH_PROMISE

Import: `"http/parser"`.

```vex
export const FRAME_PUSH_PROMISE: u8=0x5;
```

<a id="FRAME_PING"></a>

### FRAME_PING

Import: `"http/parser"`.

```vex
export const FRAME_PING: u8=0x6;
```

<a id="FRAME_GOAWAY"></a>

### FRAME_GOAWAY

Import: `"http/parser"`.

```vex
export const FRAME_GOAWAY: u8=0x7;
```

<a id="FRAME_WINDOW_UPDATE"></a>

### FRAME_WINDOW_UPDATE

Import: `"http/parser"`.

```vex
export const FRAME_WINDOW_UPDATE: u8=0x8;
```

<a id="FRAME_CONTINUATION"></a>

### FRAME_CONTINUATION

Import: `"http/parser"`.

```vex
export const FRAME_CONTINUATION: u8=0x9;
```

<a id="FRAME_PRIORITY_UPDATE"></a>

### FRAME_PRIORITY_UPDATE

Import: `"http/parser"`.

```vex
export const FRAME_PRIORITY_UPDATE: u8=0x10;
```

RFC 9218 extensible HTTP priority signal.

<a id="FLAG_END_STREAM"></a>

### FLAG_END_STREAM

Import: `"http/parser"`.

```vex
export const FLAG_END_STREAM: u8=0x1;
```

<a id="FLAG_ACK"></a>

### FLAG_ACK

Import: `"http/parser"`.

```vex
export const FLAG_ACK: u8=0x1;
```

<a id="FLAG_END_HEADERS"></a>

### FLAG_END_HEADERS

Import: `"http/parser"`.

```vex
export const FLAG_END_HEADERS: u8=0x4;
```

<a id="FLAG_PADDED"></a>

### FLAG_PADDED

Import: `"http/parser"`.

```vex
export const FLAG_PADDED: u8=0x8;
```

<a id="FLAG_PRIORITY_F"></a>

### FLAG_PRIORITY_F

Import: `"http/parser"`.

```vex
export const FLAG_PRIORITY_F: u8=0x20;
```

<a id="H2_SETTINGS_HEADER_TABLE_SIZE"></a>

### H2_SETTINGS_HEADER_TABLE_SIZE

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_HEADER_TABLE_SIZE: u8=1;
```

<a id="H2_SETTINGS_ENABLE_PUSH"></a>

### H2_SETTINGS_ENABLE_PUSH

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_ENABLE_PUSH: u8=2;
```

<a id="H2_SETTINGS_MAX_CONCURRENT_STREAMS"></a>

### H2_SETTINGS_MAX_CONCURRENT_STREAMS

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_MAX_CONCURRENT_STREAMS: u8=4;
```

<a id="H2_SETTINGS_INITIAL_WINDOW_SIZE"></a>

### H2_SETTINGS_INITIAL_WINDOW_SIZE

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_INITIAL_WINDOW_SIZE: u8=8;
```

<a id="H2_SETTINGS_MAX_FRAME_SIZE"></a>

### H2_SETTINGS_MAX_FRAME_SIZE

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_MAX_FRAME_SIZE: u8=16;
```

<a id="H2_SETTINGS_MAX_HEADER_LIST_SIZE"></a>

### H2_SETTINGS_MAX_HEADER_LIST_SIZE

Import: `"http/parser"`.

```vex
export const H2_SETTINGS_MAX_HEADER_LIST_SIZE: u8=32;
```

<a id="H2_DEFAULT_URGENCY"></a>

### H2_DEFAULT_URGENCY

Import: `"http/parser"`.

```vex
export const H2_DEFAULT_URGENCY: u8=3;
```

<a id="H2_MAX_PRIORITY_FIELD_BYTES"></a>

### H2_MAX_PRIORITY_FIELD_BYTES

Import: `"http/parser"`.

```vex
export const H2_MAX_PRIORITY_FIELD_BYTES: usize=1024;
```

<a id="OP_CONTINUATION"></a>

### OP_CONTINUATION

Import: `"http/parser"`.

```vex
export const OP_CONTINUATION: u8=0x0;
```

<a id="OP_TEXT"></a>

### OP_TEXT

Import: `"http/parser"`.

```vex
export const OP_TEXT: u8=0x1;
```

<a id="OP_BINARY"></a>

### OP_BINARY

Import: `"http/parser"`.

```vex
export const OP_BINARY: u8=0x2;
```

<a id="OP_CLOSE"></a>

### OP_CLOSE

Import: `"http/parser"`.

```vex
export const OP_CLOSE: u8=0x8;
```

<a id="OP_PING"></a>

### OP_PING

Import: `"http/parser"`.

```vex
export const OP_PING: u8=0x9;
```

<a id="OP_PONG"></a>

### OP_PONG

Import: `"http/parser"`.

```vex
export const OP_PONG: u8=0xA;
```

<a id="CLOSE_NORMAL"></a>

### CLOSE_NORMAL

Import: `"http/parser"`.

```vex
export const CLOSE_NORMAL: u16=1000;
```

<a id="CLOSE_GOING_AWAY"></a>

### CLOSE_GOING_AWAY

Import: `"http/parser"`.

```vex
export const CLOSE_GOING_AWAY: u16=1001;
```

<a id="CLOSE_PROTOCOL_ERROR"></a>

### CLOSE_PROTOCOL_ERROR

Import: `"http/parser"`.

```vex
export const CLOSE_PROTOCOL_ERROR: u16=1002;
```

<a id="STATUS_OK"></a>

### STATUS_OK

Import: `"http"`.

```vex
export const STATUS_OK: i32=200;
```

<a id="STATUS_CREATED"></a>

### STATUS_CREATED

Import: `"http"`.

```vex
export const STATUS_CREATED: i32=201;
```

<a id="STATUS_ACCEPTED"></a>

### STATUS_ACCEPTED

Import: `"http"`.

```vex
export const STATUS_ACCEPTED: i32=202;
```

<a id="STATUS_NO_CONTENT"></a>

### STATUS_NO_CONTENT

Import: `"http"`.

```vex
export const STATUS_NO_CONTENT: i32=204;
```

<a id="STATUS_RESET_CONTENT"></a>

### STATUS_RESET_CONTENT

Import: `"http"`.

```vex
export const STATUS_RESET_CONTENT: i32=205;
```

<a id="STATUS_PARTIAL_CONTENT"></a>

### STATUS_PARTIAL_CONTENT

Import: `"http"`.

```vex
export const STATUS_PARTIAL_CONTENT: i32=206;
```

<a id="STATUS_MOVED_PERMANENTLY"></a>

### STATUS_MOVED_PERMANENTLY

Import: `"http"`.

```vex
export const STATUS_MOVED_PERMANENTLY: i32=301;
```

<a id="STATUS_FOUND"></a>

### STATUS_FOUND

Import: `"http"`.

```vex
export const STATUS_FOUND: i32=302;
```

<a id="STATUS_NOT_MODIFIED"></a>

### STATUS_NOT_MODIFIED

Import: `"http"`.

```vex
export const STATUS_NOT_MODIFIED: i32=304;
```

<a id="STATUS_TEMPORARY_REDIRECT"></a>

### STATUS_TEMPORARY_REDIRECT

Import: `"http"`.

```vex
export const STATUS_TEMPORARY_REDIRECT: i32=307;
```

<a id="STATUS_PERMANENT_REDIRECT"></a>

### STATUS_PERMANENT_REDIRECT

Import: `"http"`.

```vex
export const STATUS_PERMANENT_REDIRECT: i32=308;
```

<a id="STATUS_BAD_REQUEST"></a>

### STATUS_BAD_REQUEST

Import: `"http"`.

```vex
export const STATUS_BAD_REQUEST: i32=400;
```

<a id="STATUS_UNAUTHORIZED"></a>

### STATUS_UNAUTHORIZED

Import: `"http"`.

```vex
export const STATUS_UNAUTHORIZED: i32=401;
```

<a id="STATUS_FORBIDDEN"></a>

### STATUS_FORBIDDEN

Import: `"http"`.

```vex
export const STATUS_FORBIDDEN: i32=403;
```

<a id="STATUS_NOT_FOUND"></a>

### STATUS_NOT_FOUND

Import: `"http"`.

```vex
export const STATUS_NOT_FOUND: i32=404;
```

<a id="STATUS_METHOD_NOT_ALLOWED"></a>

### STATUS_METHOD_NOT_ALLOWED

Import: `"http"`.

```vex
export const STATUS_METHOD_NOT_ALLOWED: i32=405;
```

<a id="STATUS_CONFLICT"></a>

### STATUS_CONFLICT

Import: `"http"`.

```vex
export const STATUS_CONFLICT: i32=409;
```

<a id="STATUS_GONE"></a>

### STATUS_GONE

Import: `"http"`.

```vex
export const STATUS_GONE: i32=410;
```

<a id="STATUS_CONTENT_TOO_LARGE"></a>

### STATUS_CONTENT_TOO_LARGE

Import: `"http"`.

```vex
export const STATUS_CONTENT_TOO_LARGE: i32=413;
```

<a id="STATUS_UNPROCESSABLE_ENTITY"></a>

### STATUS_UNPROCESSABLE_ENTITY

Import: `"http"`.

```vex
export const STATUS_UNPROCESSABLE_ENTITY: i32=422;
```

<a id="STATUS_TOO_MANY_REQUESTS"></a>

### STATUS_TOO_MANY_REQUESTS

Import: `"http"`.

```vex
export const STATUS_TOO_MANY_REQUESTS: i32=429;
```

<a id="STATUS_INTERNAL_SERVER_ERROR"></a>

### STATUS_INTERNAL_SERVER_ERROR

Import: `"http"`.

```vex
export const STATUS_INTERNAL_SERVER_ERROR: i32=500;
```

<a id="STATUS_NOT_IMPLEMENTED"></a>

### STATUS_NOT_IMPLEMENTED

Import: `"http"`.

```vex
export const STATUS_NOT_IMPLEMENTED: i32=501;
```

<a id="STATUS_BAD_GATEWAY"></a>

### STATUS_BAD_GATEWAY

Import: `"http"`.

```vex
export const STATUS_BAD_GATEWAY: i32=502;
```

<a id="STATUS_SERVICE_UNAVAILABLE"></a>

### STATUS_SERVICE_UNAVAILABLE

Import: `"http"`.

```vex
export const STATUS_SERVICE_UNAVAILABLE: i32=503;
```

<a id="STATUS_GATEWAY_TIMEOUT"></a>

### STATUS_GATEWAY_TIMEOUT

Import: `"http"`.

```vex
export const STATUS_GATEWAY_TIMEOUT: i32=504;
```

<a id="WS_MAX_QUEUED_BYTES"></a>

### WS_MAX_QUEUED_BYTES

Import: `"http/ws"`.

```vex
export const WS_MAX_QUEUED_BYTES: usize=WS_MAX_BUFFER_BYTES;
```

The output limit is intentionally equal to the accepted input/message

limit. It makes a slow peer a bounded backpressure condition instead of an
unbounded worker-memory commitment.

<a id="WS_TEXT"></a>

### WS_TEXT

Import: `"http/ws"`.

```vex
export const WS_TEXT: u8=1;
```

<a id="WS_BINARY"></a>

### WS_BINARY

Import: `"http/ws"`.

```vex
export const WS_BINARY: u8=2;
```

<a id="WS_CLOSE"></a>

### WS_CLOSE

Import: `"http/ws"`.

```vex
export const WS_CLOSE: u8=8;
```

<a id="WS_PING"></a>

### WS_PING

Import: `"http/ws"`.

```vex
export const WS_PING: u8=9;
```

<a id="WS_PONG"></a>

### WS_PONG

Import: `"http/ws"`.

```vex
export const WS_PONG: u8=10;
```

<a id="WS_MAX_SUBPROTOCOLS"></a>

### WS_MAX_SUBPROTOCOLS

Import: `"http/ws"`.

```vex
export const WS_MAX_SUBPROTOCOLS: usize=32 as usize;
```

A handshake may advertise several subprotocols, but an attacker-controlled

comma list must not turn route selection into unbounded quadratic work.

<a id="AsyncBodyHandler"></a>

### AsyncBodyHandler

Import: `"http/fiber"`.

```vex
type AsyncBodyHandler = async fn(
    &Ctx!, &AsyncRequestBody!, &AsyncBodyPipelineNext!, &Context
)
```

One explicit awaitable body-route step. All middleware in this lane sees

the same task-owned request body and continuation; ordinary synchronous
Fiber middleware is never allowed to retain either value.

<a id="AsyncHandler"></a>

### AsyncHandler

Import: `"http/fiber"`.

```vex
type AsyncHandler = async fn(&Ctx!, &AsyncPipelineNext!, &Context)
```

A task-owned, awaitable Fiber handler. This is an explicit async lane;

ordinary `Handler` remains synchronous by design.

<a id="Handler"></a>

### Handler

Import: `"http/fiber"`.

```vex
type Handler = fn ( &Ctx!)
```

<a id="StreamHandler"></a>

### StreamHandler

Import: `"http/fiber"`.

```vex
type StreamHandler = fn ( &Ctx!, &ResponseStreamWriter!)
```

A bounded HTTP response producer. The route owns response metadata through

`Ctx` until its first `out.write`; afterwards `ResponseStreamWriter` is the
only path which can produce body bytes and HTTP/1 framing.

<a id="WsHandler"></a>

### WsHandler

Import: `"http/fiber"`.

```vex
type WsHandler = fn ( &WsSession!, WsMessage)
```

Runs on the owning Fiber worker for each complete WebSocket message. The

`WsSession` borrow is event-scoped: applications can queue replies but do
not receive descriptor ownership or a blocking read primitive.

<a id="WsOpenHandler"></a>

### WsOpenHandler

Import: `"http/fiber"`.

```vex
type WsOpenHandler = fn ( &WsSession!)
```

Runs after Fiber has accepted a valid upgrade and queued its `101` reply.

The borrow is worker-scoped, so opening work can queue a welcome frame but
cannot take ownership of the descriptor.

<a id="WsCloseHandler"></a>

### WsCloseHandler

Import: `"http/fiber"`.

```vex
type WsCloseHandler = fn (u64)
```

Runs exactly once when Fiber retires a WebSocket connection. The supplied

identity is stable for the session but is never an OS descriptor. Close
hooks are observational: transport ownership has ended, so no session
handle is exposed for further I/O.

<a id="RequestHandler"></a>

### RequestHandler

Import: `"http"`.

```vex
type RequestHandler = fn (req: &Request, res: &Response!)
```

Direct request/response callback for `Server` and `App.serveDirect`.

The request is valid only for the callback. Responses are buffered into the
worker-owned connection output and drained after the callback returns.

<a id="HttpRedirectResolver"></a>

### HttpRedirectResolver

Import: `"http"`.

```vex
export contract HttpRedirectResolver {
    async fn resolve(
        host: str, port: u16, context: &Context,
    ): Result<SocketAddr, IoError>;
}
```

Async authority-to-endpoint boundary used only by cross-origin redirects.

Implementations receive an HTTP host and effective port. They may consult
an application-owned pre-resolved map or an async resolver, but must not
perform blocking DNS on a scheduler worker. Same-origin redirects never
invoke this contract and keep using the caller's original endpoint.

<a id="RequestBodyConsumer"></a>

### RequestBodyConsumer

Import: `"http"`, `"http/parser"`.

```vex
export contract RequestBodyConsumer: ChunkSink {
    begin(info: BodyConsumerStart)!: bool;
    acceptChunk(bytes: str)!: bool;
    finish(totalBytes: usize)!: bool;
    cancel()!;
}
```

Stateful destination for one bounded decoded HTTP body.

The lifecycle is deliberately synchronous at the byte-delivery seam:
`acceptChunk` receives a borrowed transport view, so acknowledging it after
an `await` would be an ownership violation. Async Fiber routes will place
owned fixed-capacity pages *before* this contract, not turn this contract
into a raw descriptor callback.

<a id="ChunkSink"></a>

### ChunkSink

Import: `"http/parser"`.

```vex
export contract ChunkSink {
    acceptChunk(bytes: str)!: bool;
}
```

Destination for decoded transfer-coding payload bytes.

The view is borrowed from the current transport fragment and is valid only
for this call. Returning `false` aborts decoding without accepting later
transport bytes. This is a statically-dispatched contract: a streaming
consumer does not pay for a closure, allocation, or virtual call.

<a id="MultipartSink"></a>

### MultipartSink

Import: `"http"`, `"http/parser"`.

```vex
export contract MultipartSink {
    beginPart(info: MultipartPartInfo)!: bool;
    partHeader(name: str, value: str)!: bool;
    acceptPartChunk(bytes: str)!: bool;
    endPart()!: bool;
    finishMultipart(partCount: usize)!: bool;
    cancelMultipart()!;
}
```

Synchronous destination for one decoded multipart stream. The contract is

deliberately allocation-free and non-awaitable at the byte seam: Fiber's
task-owned page ring has already established ownership before invoking it.

<a id="HttpClientConfig"></a>

### HttpClientConfig

Import: `"http"`.

```vex
export struct HttpClientConfig
```

Resource limits for one HTTP/1.1 request/response exchange.

Zero limits are never treated as "unbounded": use `defaults()` and modify
an explicit field instead. The parser itself has a structural 64-header
ceiling, therefore `maxResponseHeaders` may not exceed 64.

**Implements:** `Copy`

**Public fields:**

- `maxRequestBytes`: `usize`
- `maxResponseHeaderBytes`: `usize`
- `maxResponseBodyBytes`: `usize`
- `maxResponseHeaders`: `usize`
- `maxInformationalResponses`: `usize`

<a id="HttpClient"></a>

### HttpClient

Import: `"http"`.

```vex
export struct HttpClient
```

Stateless HTTP/1.1 transport configuration. The type intentionally owns

no socket pool yet: closing every exchange makes response framing exact and
is safer than pretending that partially supported keep-alive is reusable.

<a id="HttpRedirectPolicy"></a>

### HttpRedirectPolicy

Import: `"http"`.

```vex
export struct HttpRedirectPolicy
```

Explicit policy for buffered redirect following.

Zero is deliberately invalid: callers that do not want redirects use
`send`, while redirect-enabled code always has a finite, visible bound.

**Public fields:**

- `maxRedirects`: `usize`

<a id="HttpContentDecoding"></a>

### HttpContentDecoding

Import: `"http"`.

```vex
export struct HttpContentDecoding
```

Explicit decoded-response resource policy.

Encoded transfer bytes remain bounded by `HttpClientConfig`; this second
ceiling applies after every Content-Encoding layer and prevents compressed
payloads from turning a small wire response into an allocation bomb.

**Public fields:**

- `maxDecodedBodyBytes`: `usize`
- `maxEncodingLayers`: `usize`

<a id="ClientResponse"></a>

### ClientResponse

Import: `"http"`.

```vex
export struct ClientResponse
```

Fully decoded and owning HTTP response. A transport/protocol failure is

represented by `Result.Err(IoError)`, never by a magic invalid response.

**Public fields:**

- `status`: `i32`
- `statusText`: `string`
- `version`: `string`
- `headers`: `Headers`
- `body`: `string`
- `connectionWillClose`: `bool`

<a id="ClientResponseHead"></a>

### ClientResponseHead

Import: `"http"`.

```vex
export struct ClientResponseHead
```

Final response metadata for `HttpClient.sendInto`. The body has already

been decoded into the caller-provided async writer, so this value never
owns an unbounded payload.

**Public fields:**

- `status`: `i32`
- `statusText`: `string`
- `version`: `string`
- `headers`: `Headers`
- `connectionWillClose`: `bool`

<a id="HttpSession"></a>

### HttpSession

Import: `"http"`.

```vex
export struct HttpSession
```

One caller-owned, sequential HTTP/1.1 keep-alive connection.

This is deliberately not a shared pool. It has no lock, queue, background
reaper, or cross-task ownership ambiguity: one task owns one session and
performs one request at a time. The session closes itself on every framing,
I/O, cancellation, upgrade, HTTP/1.0, close-delimited, or `Connection:
close` boundary. A future pool can therefore contain only already-proven
reusable sessions rather than duplicating HTTP parsing policy.

**Implements:** `Drop`

<a id="ClientRequest"></a>

### ClientRequest

Import: `"http"`.

```vex
export struct ClientRequest
```

Request builder. `host` is the HTTP authority sent in `Host`; `endpoint`

is deliberately supplied separately to `HttpClient.send`, allowing a
resolved address and a virtual-host authority to differ safely.

**Public fields:**

- `method`: `string`
- `host`: `string`
- `path`: `string`
- `headers`: `Headers`
- `body`: `string`

<a id="AppConfig"></a>

### AppConfig

Import: `"http/fiber"`.

```vex
export struct AppConfig {
    public:
    bodyLimit: usize,
    maxHeaderBytes: usize,
    maxHeaders: usize,
    responseBatchBytes: usize,
    readTimeout: i32,
    writeTimeout: i32,
    idleTimeout: i32,
    maxConnections: i32,
}
```

<a id="App"></a>

### App

Import: `"http/fiber"`.

```vex
export struct App<const FEATURES: u32 = HTTP_FULL>: BufferedApplicationDispatcher {
    public:
    config: AppConfig,
    router: Router<{FEATURES}>,
    middlewares: Vec<Handler>,
    frozenMiddlewares: Vec<Handler>,
    notFoundHandler: Option<Handler>,
    errorHandler: Option<Handler>,
    directHandler: Option<RequestHandler>,
    frozen: bool,
}
```

**Implements:** `BufferedApplicationDispatcher`

<a id="AsyncBodyPipelineNext"></a>

### AsyncBodyPipelineNext

Import: `"http/fiber"`.

```vex
export struct AsyncBodyPipelineNext
```

<a id="AsyncRequestBody"></a>

### AsyncRequestBody

Import: `"http/fiber"`.

```vex
export struct AsyncRequestBody
```

Sole owner of one streamed HTTP/1 request after Fiber unregisters the

descriptor. `consume` may be called once; completion, rejection, EOF and
Context cancellation all terminate the same RequestBodyLifecycle.

<a id="AsyncPipelineNext"></a>

### AsyncPipelineNext

Import: `"http/fiber"`.

```vex
export struct AsyncPipelineNext
```

Monotonic continuation state for one task-owned request.

The continuation owns its handler vector. That makes its lifetime and
storage independent of its caller and prevents a suspended request from
observing a reallocated external Vec.

<a id="ConnBuf"></a>

### ConnBuf

Import: `"http/fiber"`.

```vex
export struct ConnBuf
```

**Public fields:**

- `data`: `Vec<u8>`
- `readPos`: `usize`
- `writePos`: `usize`

<a id="Connection"></a>

### Connection

Import: `"http/fiber"`.

```vex
export struct Connection
```

**Public fields:**

- `fd`: `i32`
- `buf`: `ConnBuf`
- `keepAlive`: `bool`
- `headerLen`: `i32`

<a id="ResponseStreamWriter"></a>

### ResponseStreamWriter

Import: `"http/fiber"`.

```vex
export struct ResponseStreamWriter
```

Connection-bound dynamic response writer used only by Fiber stream routes.

It never exposes an fd to application code, retains a fixed-size buffer and
shares one absolute deadline across headers, every chunk and the terminator.

<a id="Ctx"></a>

### Ctx

Import: `"http/fiber"`.

```vex
export struct Ctx
```

**Public fields:**

- `req`: `Request`
- `res`: `Response`
- `ownedRequestParts`: `Vec<string>`
- `routeId`: `i32`
- `routePath`: `str`
- `staticRoot`: `str`
- `routeParams`: `Vec<RouteParam>`
- `queryParams`: `Vec<QueryParam>`
- `locals`: `Vec<LocalEntry>`
- `handlers`: `Vec<Handler>`
- `routeMiddlewares`: `Vec<Handler>`
- `handlerIdx`: `usize`
- `cookieParsed`: `bool`
- `parsedCookies`: `Vec<CookiePair>`
- `streamFileLength`: `u64`
- `streamFilePending`: `bool`
- `streamFile`: `Option<File>`
- `streamHandler`: `Option<StreamHandler>`
- `streamWriter`: `Ptr<ResponseStreamWriter!>`
- `wsUpgrade`: `Ptr<WsUpgradeScratch!>`

<a id="RouteParam"></a>

### RouteParam

Import: `"http/fiber"`.

```vex
export struct RouteParam
```

Key-value pair for route parameters.

`routeParams[i]` is read out of a shared `&Ctx` by value, so the pair must
own copy semantics: four scalars/raw descriptors, no destructor. Without
the declaration every read out of a `&Ctx` is a move out of borrowed
storage and the borrow checker has to reject it.

**Implements:** `Copy`

**Public fields:**

- `keyPtr`: `Ptr<u8>`
- `keyLength`: `usize`
- `valueStart`: `usize`
- `valueLength`: `usize`

<a id="QueryParam"></a>

### QueryParam

Import: `"http/fiber"`.

```vex
export struct QueryParam
```

Query parameter represented entirely by offsets into Request.query.

**Public fields:**

- `keyStart`: `usize`
- `keyLength`: `usize`
- `valueStart`: `usize`
- `valueLength`: `usize`

<a id="LocalEntry"></a>

### LocalEntry

Import: `"http/fiber"`.

```vex
export struct LocalEntry
```

Key-value pair for user-defined locals (middleware data passing).

**Public fields:**

- `key`: `string`
- `value`: `string`

<a id="Group"></a>

### Group

Import: `"http/fiber"`.

```vex
export struct Group<const FEATURES: u32 = HTTP_FULL> {
    public:
        prefix: string,
        router: &Router<{FEATURES}>!,
        middlewares: Vec<Handler>,
        bodyMiddlewares: Vec<AsyncBodyHandler>,
}
```

<a id="RadixTree"></a>

### RadixTree

Import: `"http/fiber"`.

```vex
export struct RadixTree
```

**Public fields:**

- `parents`: `Vec<i32>`
- `firstChild`: `Vec<i32>`
- `nextSibling`: `Vec<i32>`
- `prefixes`: `Vec<string>`
- `kinds`: `Vec<i32>`
- `paramNames`: `Vec<string>`
- `handlerIdx`: `Vec<i32>`
- `handlerPool`: `Vec<Handler>`
- `hasHandlers`: `Vec<bool>`
- `mwStart`: `Vec<usize>`
- `mwLen`: `Vec<usize>`
- `mwPool`: `Vec<Handler>`
- `routeIdx`: `Vec<i32>`

<a id="MatchResult"></a>

### MatchResult

Import: `"http/fiber"`.

```vex
export struct MatchResult
```

**Public fields:**

- `found`: `bool`
- `handler`: `Option<Handler>`
- `params`: `Vec<ParamPair>`
- `middlewares`: `Vec<Handler>`

<a id="ParamPair"></a>

### ParamPair

Import: `"http/fiber"`.

```vex
export struct ParamPair
```

**Public fields:**

- `key`: `string`
- `value`: `string`

<a id="WsRouteOptions"></a>

### WsRouteOptions

Import: `"http/fiber"`.

```vex
export struct WsRouteOptions
```

Immutable WebSocket handshake policy compiled into route metadata. Protocol

insertion order is server preference order; no per-request protocol vector
is constructed on the hot path.

<a id="Router"></a>

### Router

Import: `"http/fiber"`.

```vex
export struct Router<const FEATURES: u32 = HTTP_FULL> {
    public:
    routeMethodIds: Vec<i32>,
    routePatterns: Vec<string>,
    routeStaticRoots: Vec<string>,
    routeParamNameStart: Vec<usize>,
    routeParamNameLen: Vec<usize>,
    routeParamNamePool: Vec<string>,
    routeHandlers: Vec<Handler>,
    routeIsStatic: Vec<bool>,
    routeMwStart: Vec<usize>,
    routeMwLen: Vec<usize>,
    routeMwPool: Vec<Handler>,
    protocolRoutes: RouteCapabilityState<{FEATURES}>,
    trees: Vec<RadixTree>,
    frozen: bool,
    cacheMid: i32,
    cachePath: string,
    cacheIdx: i32,
}
```

<a id="HeaderEntry"></a>

### HeaderEntry

Import: `"http"`.

```vex
export struct HeaderEntry
```

**Public fields:**

- `name`: `string`
- `value`: `string`

<a id="RequestHeaders"></a>

### RequestHeaders

Import: `"http"`.

```vex
export struct RequestHeaders
```

**Public fields:**

- `names`: `Vec<str>`
- `values`: `Vec<str>`

<a id="Headers"></a>

### Headers

Import: `"http"`.

```vex
export struct Headers
```

**Public fields:**

- `names`: `Vec<string>`
- `values`: `Vec<string>`

<a id="CorsConfig"></a>

### CorsConfig

Import: `"http"`, `"http/middleware"`.

```vex
export struct CorsConfig
```

**Public fields:**

- `origin`: `string`
- `methods`: `string`
- `headers`: `string`
- `maxAge`: `string`
- `credentials`: `bool`

<a id="BodyProgress"></a>

### BodyProgress

Import: `"http/parser"`.

```vex
export struct BodyProgress
```

**Public fields:**

- `consumed`: `usize`
- `decoded`: `usize`

<a id="BodyConsumerStart"></a>

### BodyConsumerStart

Import: `"http"`, `"http/parser"`.

```vex
export struct BodyConsumerStart
```

Immutable metadata delivered exactly once before a streaming consumer sees

decoded bytes. `declaredLength` is -1 when the framing has no fixed decoded
length (`chunked` or `until-close`). A consumer must treat every chunk view
as borrowed from the current transport read and may not retain it.

**Public fields:**

- `mode`: `BodyMode`
- `declaredLength`: `i64`
- `maxBodyBytes`: `usize`

<a id="BodyReader"></a>

### BodyReader

Import: `"http/parser"`.

```vex
export struct BodyReader
```

**Public fields:**

- `mode`: `BodyMode`
- `consumed`: `usize`
- `expected`: `usize`
- `chunked`: `ChunkedDecoder`
- `done`: `bool`

<a id="RequestBodyLifecycle"></a>

### RequestBodyLifecycle

Import: `"http"`, `"http/parser"`.

```vex
export struct RequestBodyLifecycle
```

Owns exactly one `BodyReader` plus the begin/finish/cancel transition for a

route-owned consumer. This is the only place a future Fiber body lane may
translate parser completion or transport failure into consumer lifecycle
calls; it prevents multipart/proxy helpers from inventing competing body
decoders or success-on-error behavior.

**Public fields:**

- `reader`: `BodyReader`
- `delivery`: `DecodedBodyLifecycle`

<a id="DecodedBodyLifecycle"></a>

### DecodedBodyLifecycle

Import: `"http"`, `"http/parser"`.

```vex
export struct DecodedBodyLifecycle
```

Protocol-neutral owner of the application body-consumer contract.

HTTP/1 feeds this owner after `BodyReader` removes transfer framing. HTTP/2
feeds it directly from validated DATA payloads. Keeping admission, byte
limits, declared-length accounting and terminal callbacks here prevents
each transport from inventing subtly different body semantics.

**Public fields:**

- `state`: `BodyConsumerState`
- `mode`: `BodyMode`
- `declaredLength`: `i64`
- `maxBodyBytes`: `usize`
- `totalBytes`: `usize`

<a id="BodyPageRing"></a>

### BodyPageRing

Import: `"http"`, `"http/parser"`.

```vex
export struct BodyPageRing
```

Fixed-capacity storage for Fiber's task-owned asynchronous request-body

lane. `BodyReader` still presents decoded chunks as borrowed views; this
ring is the ownership boundary used before forwarding decoded bytes to the
route-owned consumer.
Storage is allocated once at construction and never grows. Both readable
and writable views stop at a logical page boundary, so a task can release
one fixed page at a time without exposing an interior allocation or making
a peer-controlled fragment size affect retained memory. This type itself is
deliberately single-owner: the Fiber handoff transfers the descriptor and
its ring together rather than sharing mutable pages between worker and task.

<a id="ChunkProgress"></a>

### ChunkProgress

Import: `"http/parser"`.

```vex
export struct ChunkProgress
```

Progress is relative to the input passed to the current `decodeInto` call.

The caller must retain `input[consumed..]` when `NeedMore` is returned.

**Public fields:**

- `consumed`: `usize`
- `decoded`: `usize`

<a id="ChunkedDecoder"></a>

### ChunkedDecoder

Import: `"http/parser"`.

```vex
export struct ChunkedDecoder
```

**Public fields:**

- `state`: `ChunkState`
- `dataRemaining`: `usize`
- `totalDecoded`: `usize`
- `trailerBytes`: `usize`

<a id="FiberRequestLimits"></a>

### FiberRequestLimits

Import: `"http/parser"`.

```vex
export struct FiberRequestLimits
```

**Public fields:**

- `maxHeaderBytes`: `usize`
- `maxHeaders`: `usize`

<a id="FiberHeader"></a>

### FiberHeader

Import: `"http/parser"`.

```vex
export struct FiberHeader
```

**Implements:** `Copy`

**Public fields:**

- `name`: `str`
- `value`: `str`

<a id="FiberParsedRequest"></a>

### FiberParsedRequest

Import: `"http/parser"`.

```vex
export struct FiberParsedRequest {
    public:
    _raw_owned: string,
    method: str,
    uri: str,
    path: str,
    query: str,
    version: str,
    headers: Vec<FiberHeader>,
    contentLength: i64,
    chunked: bool,
    keepAlive: bool,
}
```

<a id="H2Frame"></a>

### H2Frame

Import: `"http/parser"`.

```vex
export struct H2Frame
```

**Public fields:**

- `length`: `u32`
- `frameType`: `u8`
- `flags`: `u8`
- `streamId`: `u32`

<a id="H2Settings"></a>

### H2Settings

Import: `"http/parser"`.

```vex
export struct H2Settings
```

**Public fields:**

- `headerTableSize`: `u32`
- `enablePush`: `bool`
- `maxConcurrentStreams`: `u32`
- `initialWindowSize`: `u32`
- `maxFrameSize`: `u32`
- `maxHeaderListSize`: `u32`

<a id="GoAway"></a>

### GoAway

Import: `"http/parser"`.

```vex
export struct GoAway
```

**Public fields:**

- `lastStreamId`: `u32`
- `errorCode`: `u32`
- `debugData`: `str`

<a id="H2LegacyPriority"></a>

### H2LegacyPriority

Import: `"http/parser"`.

```vex
export struct H2LegacyPriority
```

Deprecated RFC 7540 dependency metadata retained only for HTTP/2 wire

interoperability. Modern scheduling uses RFC 9218 `H2Priority` instead.

**Public fields:**

- `streamDependency`: `u32`
- `weight`: `u16`
- `exclusive`: `bool`

<a id="H2ConnectionState"></a>

### H2ConnectionState

Import: `"http/parser"`.

```vex
export struct H2ConnectionState
```

**Public fields:**

- `role`: `H2EndpointRole`
- `recvContinuationStreamId`: `u32`
- `sendContinuationStreamId`: `u32`
- `outstandingLocalSettings`: `u32`
- `pendingPeerSettingsAcks`: `u32`
- `sendWindow`: `i32`
- `recvWindow`: `i32`
- `receivedGoAway`: `bool`
- `sentGoAway`: `bool`
- `receivedLastStreamId`: `u32`
- `sentLastStreamId`: `u32`
- `nextLocalStreamId`: `u32`
- `highestRemoteStreamId`: `u32`

<a id="H2FieldSectionInfo"></a>

### H2FieldSectionInfo

Import: `"http/parser"`.

```vex
export struct H2FieldSectionInfo
```

Successful validation metadata. `statusCode` is zero for non-responses.

**Implements:** `Copy`

**Public fields:**

- `statusCode`: `u16`
- `methodIndex`: `usize`
- `schemeIndex`: `usize`
- `authorityIndex`: `usize`
- `pathIndex`: `usize`
- `statusIndex`: `usize`
- `regularStart`: `usize`
- `contentLength`: `i64`

<a id="H2Priority"></a>

### H2Priority

Import: `"http/parser"`.

```vex
export struct H2Priority
```

**Public fields:**

- `urgency`: `u8`
- `incremental`: `bool`

<a id="H2PriorityUpdate"></a>

### H2PriorityUpdate

Import: `"http/parser"`.

```vex
export struct H2PriorityUpdate
```

**Public fields:**

- `streamId`: `u32`
- `priority`: `H2Priority`

<a id="H2PriorityScheduler"></a>

### H2PriorityScheduler

Import: `"http/parser"`.

```vex
export struct H2PriorityScheduler
```

<a id="H2ProtocolConfig"></a>

### H2ProtocolConfig

Import: `"http/parser"`.

```vex
export struct H2ProtocolConfig
```

**Implements:** `Copy`

**Public fields:**

- `maxConcurrentStreams`: `u32`
- `maximumChunkBytes`: `u32`
- `starvationTurns`: `u64`
- `maxHeaderBlockBytes`: `usize`
- `hpackLimits`: `HpackDecodeLimits`
- `maxOutstandingSettings`: `u32`
- `maxOutstandingPings`: `u32`

<a id="H2HeaderFragment"></a>

### H2HeaderFragment

Import: `"http/parser"`.

```vex
export struct H2HeaderFragment
```

One wire fragment of a successfully committed outbound HPACK block.

`payloadOffset` and `payloadBytes` slice the caller-owned contiguous block;
transport prepends `frame` and never copies compression state.

**Public fields:**

- `frame`: `H2Frame`
- `promisedStreamId`: `u32`
- `payloadOffset`: `usize`
- `payloadBytes`: `usize`

<a id="H2HeaderFrameCursor"></a>

### H2HeaderFrameCursor

Import: `"http/parser"`.

```vex
export struct H2HeaderFrameCursor
```

Allocation-free HEADERS/CONTINUATION cursor bound to the peer's effective

SETTINGS_MAX_FRAME_SIZE at the same transaction that encoded the block.

<a id="H2ProtocolState"></a>

### H2ProtocolState

Import: `"http/parser"`.

```vex
export struct H2ProtocolState
```

<a id="HeaderEntry-2"></a>

### HeaderEntry

Import: `"http/parser"`.

```vex
export struct HeaderEntry
```

**Implements:** `Copy`

**Public fields:**

- `name`: `str`
- `value`: `str`

<a id="ParserHeaders"></a>

### ParserHeaders

Import: `"http/parser"`.

```vex
export struct ParserHeaders
```

**Public fields:**

- `entries`: `[HeaderEntry; 64]`
- `count`: `usize`

<a id="DynamicTable"></a>

### DynamicTable

Import: `"http/parser"`.

```vex
export struct DynamicTable
```

**Public fields:**

- `entries`: `Vec<DynEntry>`
- `size`: `usize`
- `maxSize`: `usize`
- `allowedMaxSize`: `usize`
- `requiredSizeUpdate`: `bool`
- `requiredSizeUpdateMaximum`: `usize`

<a id="HpackHeader"></a>

### HpackHeader

Import: `"http/parser"`.

```vex
export struct HpackHeader
```

**Public fields:**

- `name`: `string`
- `value`: `string`
- `indexing`: `HpackIndexing`

<a id="HpackDecodeLimits"></a>

### HpackDecodeLimits

Import: `"http/parser"`.

```vex
export struct HpackDecodeLimits
```

Explicit resource policy for one complete HPACK header block.

**Implements:** `Copy`

**Public fields:**

- `maxHeaderListBytes`: `usize`
- `maxHeaderCount`: `usize`
- `maxStringBytes`: `usize`
- `maxDynamicTableSize`: `usize`

<a id="HpackEncodeLimits"></a>

### HpackEncodeLimits

Import: `"http/parser"`.

```vex
export struct HpackEncodeLimits
```

**Implements:** `Copy`

**Public fields:**

- `maxHeaderListBytes`: `usize`
- `maxHeaderCount`: `usize`
- `maxStringBytes`: `usize`
- `maxBlockBytes`: `usize`
- `useHuffman`: `bool`

<a id="HpackEncoder"></a>

### HpackEncoder

Import: `"http/parser"`.

```vex
export struct HpackEncoder
```

Connection-lifetime encoder state. Peer SETTINGS changes are applied to

table capacity immediately and emitted at the beginning of the next block.
A reduction followed by an increase retains both the smallest observed
value and the final value, as required by RFC 7541 §4.2.

<a id="MultipartLimits"></a>

### MultipartLimits

Import: `"http"`, `"http/parser"`.

```vex
export struct MultipartLimits
```

**Implements:** `Copy`

**Public fields:**

- `maxParts`: `usize`
- `maxPartHeaderBytes`: `usize`
- `maxHeadersPerPart`: `usize`
- `maxNameBytes`: `usize`
- `maxFileNameBytes`: `usize`

<a id="MultipartPartInfo"></a>

### MultipartPartInfo

Import: `"http"`, `"http/parser"`.

```vex
export struct MultipartPartInfo
```

Metadata views are valid only during `beginPart`. A sink which retains a

name or filename must copy it into its own storage.

**Public fields:**

- `index`: `usize`
- `name`: `str`
- `fileName`: `str`
- `hasFileName`: `bool`
- `contentType`: `str`

<a id="MultipartConsumer"></a>

### MultipartConsumer

Import: `"http"`, `"http/parser"`.

```vex
export struct MultipartConsumer<S: MultipartSink>: RequestBodyConsumer {
    sink: &S!,
    limits: MultipartLimits,
    startMarker: string,
    bodyMarker: string,
    workspace: Vec<u8>,
    buffered: usize,
    state: MultipartState,
    partCount: usize,
    activePart: bool,
    began: bool,
    terminal: bool,
    partHasFileName: bool,
    partName: StringBuilder,
    partFileName: StringBuilder,
}
```

Fixed-budget incremental parser bound to one caller-owned sink.

**Implements:** `RequestBodyConsumer`

<a id="ParserRequest"></a>

### ParserRequest

Import: `"http/parser"`.

```vex
export struct ParserRequest
```

**Public fields:**

- `method`: `Method`
- `uri`: `str`
- `version`: `HttpVersion`
- `headers`: `ParserHeaders`

<a id="Response"></a>

### Response

Import: `"http/parser"`.

```vex
export struct Response
```

**Public fields:**

- `statusCode`: `i32`
- `reasonPhrase`: `str`
- `version`: `str`
- `headers`: `ParserHeaders`

<a id="Scanner"></a>

### Scanner

Import: `"http/parser"`.

```vex
export struct Scanner
```

**Public fields:**

- `data`: `str`
- `pos`: `usize`

<a id="H2Stream"></a>

### H2Stream

Import: `"http/parser"`.

```vex
export struct H2Stream
```

**Public fields:**

- `id`: `u32`
- `state`: `StreamState`
- `sendWindow`: `i32`
- `recvWindow`: `i32`
- `legacyWeight`: `u16`
- `legacyDependency`: `u32`
- `legacyExclusive`: `bool`
- `recvInitialHeaders`: `bool`
- `recvFinalHeaders`: `bool`
- `sendInitialHeaders`: `bool`
- `sendFinalHeaders`: `bool`
- `recvContentLength`: `i64`
- `recvContentBytes`: `u64`
- `recvContentForbidden`: `bool`
- `sentRequestHead`: `bool`
- `sentRequestConnect`: `bool`
- `recvRequestHead`: `bool`
- `recvRequestConnect`: `bool`
- `sendContentLength`: `i64`
- `sendContentBytes`: `u64`
- `sendContentForbidden`: `bool`
- `resetSent`: `bool`

<a id="StreamMap"></a>

### StreamMap

Import: `"http/parser"`.

```vex
export struct StreamMap
```

**Public fields:**

- `streams`: `Vec<H2Stream>`
- `sendInitialWindow`: `i32`
- `recvInitialWindow`: `i32`
- `maxStreams`: `u32`

<a id="WsFrame"></a>

### WsFrame

Import: `"http/parser"`.

```vex
export struct WsFrame
```

**Public fields:**

- `fin`: `bool`
- `rsv1`: `bool`
- `rsv2`: `bool`
- `rsv3`: `bool`
- `opcode`: `u8`
- `masked`: `bool`
- `payloadLen`: `u64`
- `maskKey`: `u32`
- `headerLen`: `usize`

<a id="WsMessage"></a>

### WsMessage

Import: `"http/parser"`.

```vex
export struct WsMessage
```

**Public fields:**

- `opcode`: `u8`
- `data`: `string`
- `complete`: `bool`
- `active`: `bool`

<a id="Request"></a>

### Request

Import: `"http"`.

```vex
export struct Request
```

**Public fields:**

- `method`: `str`
- `path`: `str`
- `query`: `str`
- `version`: `str`
- `scheme`: `str`
- `authority`: `str`
- `headers`: `RequestHeaders`
- `body`: `str`
- `_raw`: `str`
- `_raw_owned`: `Vec<u8>`
- `fd`: `i64`
- `streamId`: `i32`
- `valid`: `bool`
- `contentLength`: `i64`
- `keepAlive`: `bool`

<a id="Response-2"></a>

### Response

Import: `"http"`.

```vex
export struct Response
```

**Public fields:**

- `statusCode`: `i32`
- `headers`: `Headers`
- `body`: `string`
- `sent`: `bool`
- `keepAlive`: `bool`
- `buffered`: `bool`
- `bodySuppressed`: `bool`
- `bufferedContentType`: `str`
- `buffered_output`: `StringBuilder`

<a id="Server"></a>

### Server

Import: `"http"`.

```vex
export struct Server
```

**Public fields:**

- `host`: `string`
- `port`: `i32`
- `app`: `App<{HTTP_FULL}>`

<a id="WsSession"></a>

### WsSession

Import: `"http/ws"`.

```vex
export struct WsSession
```

A persistent non-blocking WebSocket endpoint. It borrows the descriptor:

the enclosing Fiber worker remains the only authority that closes it.

<a id="WsMessage-2"></a>

### WsMessage

Import: `"http/ws"`.

```vex
export struct WsMessage
```

A complete WebSocket message (possibly assembled from fragments).

**Public fields:**

- `opcode`: `u8`
- `data`: `string`

<a id="WsConn"></a>

### WsConn

Import: `"http/ws"`.

```vex
export struct WsConn
```

**Public fields:**

- `fd`: `i64`
- `open`: `bool`
- `recvBuffer`: `WsFrameStream`
- `fragmentOpcode`: `u8`
- `fragmentData`: `StringBuilder`

<a id="BodyMode"></a>

### BodyMode

Import: `"http"`, `"http/parser"`.

```vex
export enum BodyMode
```

**Variants:**

- `NoBody`
- `ContentLength`
- `Chunked`
- `UntilClose`
- `EndStream` — Decoded bytes are terminated by an explicit protocol stream boundary

<a id="BodyResult"></a>

### BodyResult

Import: `"http/parser"`.

```vex
export enum BodyResult
```

**Variants:**

- `NeedMore`
- `Complete`
- `Error`

<a id="BodyConsumerState"></a>

### BodyConsumerState

Import: `"http"`, `"http/parser"`.

```vex
export enum BodyConsumerState
```

The terminal state is explicit because a transport error after `begin`

must never look like a successful empty body to a route-level consumer.

**Variants:**

- `Idle`
- `Reading`
- `Finished`
- `Cancelled`

<a id="ChunkState"></a>

### ChunkState

Import: `"http/parser"`.

```vex
export enum ChunkState
```

**Variants:**

- `Size`
- `Data`
- `DataCRLF`
- `Trailer`
- `Done`
- `Error`

<a id="ChunkResult"></a>

### ChunkResult

Import: `"http/parser"`.

```vex
export enum ChunkResult
```

**Variants:**

- `NeedMore`
- `Complete`
- `Error`

<a id="FiberRequestResult"></a>

### FiberRequestResult

Import: `"http/parser"`.

```vex
export enum FiberRequestResult
```

**Variants:**

- `Complete`
- `Incomplete`
- `Error`

<a id="H2ParseResult"></a>

### H2ParseResult

Import: `"http/parser"`.

```vex
export enum H2ParseResult
```

**Variants:**

- `Ok` — Frame header parsed successfully.
- `NeedMore` — Need more data (at least N bytes).
- `StreamError` — Stream-scoped metadata rejection. Frame metadata is retained so a
- `ConnectionError` — Peer violation that terminates the HTTP/2 connection.
- `Invalid` — Invalid local parser configuration rather than peer input.

<a id="H2SettingsUpdateResult"></a>

### H2SettingsUpdateResult

Import: `"http/parser"`.

```vex
export enum H2SettingsUpdateResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2GoAwayResult"></a>

### H2GoAwayResult

Import: `"http/parser"`.

```vex
export enum H2GoAwayResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2WindowUpdateResult"></a>

### H2WindowUpdateResult

Import: `"http/parser"`.

```vex
export enum H2WindowUpdateResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2RstStreamResult"></a>

### H2RstStreamResult

Import: `"http/parser"`.

```vex
export enum H2RstStreamResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2LegacyPriorityResult"></a>

### H2LegacyPriorityResult

Import: `"http/parser"`.

```vex
export enum H2LegacyPriorityResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2EncodeResult"></a>

### H2EncodeResult

Import: `"http/parser"`.

```vex
export enum H2EncodeResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2EndpointRole"></a>

### H2EndpointRole

Import: `"http/parser"`.

```vex
export enum H2EndpointRole
```

**Variants:**

- `Client`
- `Server`

<a id="H2ConnectionResult"></a>

### H2ConnectionResult

Import: `"http/parser"`.

```vex
export enum H2ConnectionResult
```

**Variants:**

- `Ok`
- `HeaderBlockOpen` — A fragmented header block now owns this direction of the connection.
- `HeaderBlockComplete` — A complete header block is ready for HPACK decoding.
- `SettingsAckRequired` — Peer SETTINGS were accepted and require an acknowledgement.
- `Error` — Connection-level HTTP/2 error code and stable diagnostic.

<a id="H2FlowResult"></a>

### H2FlowResult

Import: `"http/parser"`.

```vex
export enum H2FlowResult
```

**Variants:**

- `Ok`
- `Blocked` — Local send capacity is exhausted; wait for WINDOW_UPDATE.
- `Invalid` — Invalid local API request; no flow-control state changed.
- `ConnectionError` — Peer violated the connection flow-control window.
- `StreamError` — Peer violated one stream's flow-control window.

<a id="H2StreamAdmissionResult"></a>

### H2StreamAdmissionResult

Import: `"http/parser"`.

```vex
export enum H2StreamAdmissionResult
```

**Variants:**

- `Opened` — A stream was materialized. Contains its stream identifier and map index.
- `Existing` — The stream was already materialized. Contains its identifier and index.
- `Blocked` — Local admission cannot proceed (draining, concurrency limit, exhaustion).
- `Ignored` — A peer stream above the locally sent GOAWAY boundary was consumed but ignored.
- `StreamError` — Peer admission failed at stream scope.
- `ConnectionError` — Peer admission violated a connection-wide stream-ID invariant.

<a id="H2FieldSectionKind"></a>

### H2FieldSectionKind

Import: `"http/parser"`.

```vex
export enum H2FieldSectionKind
```

The semantic context of one fully decompressed HTTP/2 field section.

**Variants:**

- `Request`
- `Response`
- `Trailers`
- `PushRequest`

<a id="H2FieldSectionResult"></a>

### H2FieldSectionResult

Import: `"http/parser"`.

```vex
export enum H2FieldSectionResult
```

**Variants:**

- `Ok`
- `Malformed`

<a id="H2PriorityFieldResult"></a>

### H2PriorityFieldResult

Import: `"http/parser"`.

```vex
export enum H2PriorityFieldResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2PriorityUpdateResult"></a>

### H2PriorityUpdateResult

Import: `"http/parser"`.

```vex
export enum H2PriorityUpdateResult
```

**Variants:**

- `Ok`
- `Error`

<a id="H2PriorityRegistrationResult"></a>

### H2PriorityRegistrationResult

Import: `"http/parser"`.

```vex
export enum H2PriorityRegistrationResult
```

**Variants:**

- `Added`
- `Updated`
- `Full`
- `Invalid`

<a id="H2ScheduleResult"></a>

### H2ScheduleResult

Import: `"http/parser"`.

```vex
export enum H2ScheduleResult
```

**Variants:**

- `Selected`
- `Empty`
- `FlowBlocked`
- `Busy`
- `Invalid`

<a id="H2ProtocolFrameResult"></a>

### H2ProtocolFrameResult

Import: `"http/parser"`.

```vex
export enum H2ProtocolFrameResult
```

**Variants:**

- `Ok`
- `HeaderBlockOpen`
- `HeaderBlockComplete`
- `SettingsAckRequired`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2ReceiveGoAwayResult"></a>

### H2ReceiveGoAwayResult

Import: `"http/parser"`.

```vex
export enum H2ReceiveGoAwayResult
```

**Variants:**

- `Applied`
- `ConnectionError`
- `Invalid`

<a id="H2SendGoAwayResult"></a>

### H2SendGoAwayResult

Import: `"http/parser"`.

```vex
export enum H2SendGoAwayResult
```

**Variants:**

- `Encoded`
- `ConnectionError`
- `Invalid`

<a id="H2ReceivePingResult"></a>

### H2ReceivePingResult

Import: `"http/parser"`.

```vex
export enum H2ReceivePingResult
```

Exact received PING ownership. Non-ACK payloads must be echoed by

`sendPingAckFrame`; ACK payloads are correlated against the bounded local
outstanding set. Unmatched ACKs are observable but not connection errors.

**Variants:**

- `AckRequired`
- `Acknowledged`
- `UnmatchedAcknowledgement`
- `ConnectionError`
- `Invalid`

<a id="H2SendPingResult"></a>

### H2SendPingResult

Import: `"http/parser"`.

```vex
export enum H2SendPingResult
```

**Variants:**

- `Encoded`
- `Duplicate`
- `Full`
- `ConnectionError`
- `Invalid`

<a id="H2ReceivePriorityResult"></a>

### H2ReceivePriorityResult

Import: `"http/parser"`.

```vex
export enum H2ReceivePriorityResult
```

Exact RFC 9218 PRIORITY_UPDATE receive ownership. Wire parsing, directional

connection sequencing and bounded scheduler mutation commit as one turn.

**Variants:**

- `Applied`
- `ConnectionError`
- `Invalid`

<a id="H2SendPriorityResult"></a>

### H2SendPriorityResult

Import: `"http/parser"`.

```vex
export enum H2SendPriorityResult
```

**Variants:**

- `Encoded`
- `ConnectionError`
- `Invalid`

<a id="H2ReceiveLegacyPriorityResult"></a>

### H2ReceiveLegacyPriorityResult

Import: `"http/parser"`.

```vex
export enum H2ReceiveLegacyPriorityResult
```

**Variants:**

- `Applied`
- `Ignored`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2ProtocolAbortResult"></a>

### H2ProtocolAbortResult

Import: `"http/parser"`.

```vex
export enum H2ProtocolAbortResult
```

**Variants:**

- `Closed`
- `AlreadyClosed`

<a id="H2HeaderFrameResult"></a>

### H2HeaderFrameResult

Import: `"http/parser"`.

```vex
export enum H2HeaderFrameResult
```

Result of connection-owned received header-block processing. A stream

error is intentionally delayed until END_HEADERS so HPACK state still
advances exactly as it did on the wire.

**Variants:**

- `Pending`
- `Decoded`
- `Ignored`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2ReceiveDataResult"></a>

### H2ReceiveDataResult

Import: `"http/parser"`.

```vex
export enum H2ReceiveDataResult
```

Result of exact-payload DATA ingestion. `Data` borrows only the application

bytes after the optional pad-length field and trailing padding; `flowBytes`
is the complete frame payload charged to both receive windows.

**Variants:**

- `Data`
- `Discarded`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2SendDataResult"></a>

### H2SendDataResult

Import: `"http/parser"`.

```vex
export enum H2SendDataResult
```

A DATA frame whose scheduler lease, stream/connection windows and stream

transition committed together. Transport writes one optional pad-length
byte, `dataBytes` application bytes, then `paddingBytes` zero bytes.

**Variants:**

- `Ready`
- `Blocked`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2SendControlResult"></a>

### H2SendControlResult

Import: `"http/parser"`.

```vex
export enum H2SendControlResult
```

Shared result for atomically encoded payload-bearing control frames.

**Variants:**

- `Encoded`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2ReceiveResetResult"></a>

### H2ReceiveResetResult

Import: `"http/parser"`.

```vex
export enum H2ReceiveResetResult
```

A peer reset whose payload, connection sequencing, stream retirement and

scheduler revocation committed together.

**Variants:**

- `Reset`
- `ConnectionError`
- `Invalid`

<a id="H2InboundFrameResult"></a>

### H2InboundFrameResult

Import: `"http/parser"`.

```vex
export enum H2InboundFrameResult
```

One transport-facing receive result for every HTTP/2 frame class. The

dispatcher preserves borrowed payload views, moves decoded header ownership
once, and retains exact stream-vs-connection error scope.

**Variants:**

- `Data`
- `DiscardedData`
- `HeaderBlockPending`
- `Headers`
- `SettingsAckRequired`
- `SettingsAcknowledged`
- `WindowUpdated`
- `Reset`
- `GoAway`
- `PingAckRequired`
- `PingAcknowledged`
- `PingUnmatched`
- `PriorityUpdated`
- `LegacyPriorityApplied`
- `LegacyPriorityIgnored`
- `Ignored`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2IngressResult"></a>

### H2IngressResult

Import: `"http/parser"`.

```vex
export enum H2IngressResult
```

One incremental transport step over caller-retained bytes. `Dispatched`

reports the exact prefix safe to consume after the result is handled;
borrowed DATA/PING/GOAWAY views remain valid until then.

**Variants:**

- `Dispatched`
- `NeedMore`
- `Invalid`

<a id="H2SendResetResult"></a>

### H2SendResetResult

Import: `"http/parser"`.

```vex
export enum H2SendResetResult
```

Result of an application cancellation/reset. Idle identifiers have no wire

representation and are retired without encoding; active streams commit
only after the complete 13-byte RST_STREAM has been encoded successfully.

**Variants:**

- `Encoded`
- `Closed`
- `IdlePriorityRemoved`
- `AlreadyClosed`
- `NotFound`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2SendHeaderResult"></a>

### H2SendHeaderResult

Import: `"http/parser"`.

```vex
export enum H2SendHeaderResult
```

Result of a semantically validated, connection-owned outbound field block.

`Encoded` returns the HPACK payload length; transport owns the nine-byte
frame header and writes it only after this transaction succeeds.

**Variants:**

- `Encoded`
- `OutputTooSmall`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="H2SendPushResult"></a>

### H2SendPushResult

Import: `"http/parser"`.

```vex
export enum H2SendPushResult
```

**Variants:**

- `Promised`
- `OutputTooSmall`
- `StreamError`
- `ConnectionError`
- `Invalid`

<a id="MessageFraming"></a>

### MessageFraming

Import: `"http/parser"`.

```vex
export enum MessageFraming
```

The sole framing decision derived from HTTP message headers.

Callers must not independently inspect `Content-Length` and
`Transfer-Encoding`: doing so is how request/response parsers disagree
about message boundaries. `Invalid` is deliberately a borrowed static
diagnostic, so the zero-copy parser stays allocation-free.

**Variants:**

- `NoFraming`
- `ContentLength`
- `Chunked`
- `Invalid`

<a id="HeaderParseResult"></a>

### HeaderParseResult

Import: `"http/parser"`.

```vex
export enum HeaderParseResult
```

Parse result for headers.

**Variants:**

- `Complete` — ParserHeaders fully parsed. Value = position after \r\n\r\n.
- `Incomplete` — Need more data (incomplete header block).
- `Error` — Malformed header line.
- `TooManyHeaders` — Too many headers.

<a id="HpackIntegerResult"></a>

### HpackIntegerResult

Import: `"http/parser"`.

```vex
export enum HpackIntegerResult
```

**Variants:**

- `Ok`
- `NeedMore`
- `Error`

<a id="HpackIndexing"></a>

### HpackIndexing

Import: `"http/parser"`.

```vex
export enum HpackIndexing
```

Encoding policy for one HPACK field. Decoded literals preserve their wire

policy; indexed fields decode as `Auto` because they carry no literal flag.

**Variants:**

- `Auto`
- `Incremental`
- `Without`
- `Never`

<a id="HpackResult"></a>

### HpackResult

Import: `"http/parser"`.

```vex
export enum HpackResult
```

**Variants:**

- `Ok` — Decoded one header.
- `TableUpdate` — Dynamic table size update (not a header).
- `NeedMore` — Need more data.
- `Error` — Decode error.

<a id="HpackBlockResult"></a>

### HpackBlockResult

Import: `"http/parser"`.

```vex
export enum HpackBlockResult
```

**Variants:**

- `Ok`
- `Error`

<a id="HpackEncodeResult"></a>

### HpackEncodeResult

Import: `"http/parser"`.

```vex
export enum HpackEncodeResult
```

**Variants:**

- `Ok`
- `OutputTooSmall`
- `Error`

<a id="HuffDecodeResult"></a>

### HuffDecodeResult

Import: `"http/parser"`.

```vex
export enum HuffDecodeResult
```

Decode result.

**Variants:**

- `Ok` — Successfully decoded. usize = bytes written to output.
- `Error` — Invalid Huffman sequence.

<a id="MultipartState"></a>

### MultipartState

Import: `"http"`, `"http/parser"`.

```vex
export enum MultipartState
```

**Variants:**

- `Start`
- `Headers`
- `Body`
- `BoundarySuffix`
- `Done`
- `Failed`

<a id="Method"></a>

### Method

Import: `"http/parser"`.

```vex
export enum Method
```

**Variants:**

- `GET`
- `POST`
- `PUT`
- `DELETE`
- `PATCH`
- `HEAD`
- `OPTIONS`
- `CONNECT`
- `TRACE`
- `Unknown`

<a id="HttpVersion"></a>

### HttpVersion

Import: `"http/parser"`.

```vex
export enum HttpVersion
```

**Variants:**

- `Http10`
- `Http11`
- `Unknown`

<a id="RequestResult"></a>

### RequestResult

Import: `"http/parser"`.

```vex
export enum RequestResult
```

**Variants:**

- `Complete` — Fully parsed. usize = byte offset where body starts.
- `Incomplete` — Need more data (headers not complete).
- `Error` — Protocol error.

<a id="ResponseResult"></a>

### ResponseResult

Import: `"http/parser"`.

```vex
export enum ResponseResult
```

**Variants:**

- `Complete` — Fully parsed. usize = byte offset where body starts.
- `Incomplete` — Need more data.
- `Error` — Protocol error.

<a id="StreamState"></a>

### StreamState

Import: `"http/parser"`.

```vex
export enum StreamState
```

**Variants:**

- `Idle`
- `ReservedLocal`
- `ReservedRemote`
- `Open`
- `HalfClosedLocal`
- `HalfClosedRemote`
- `Closed`

<a id="StreamError"></a>

### StreamError

Import: `"http/parser"`.

```vex
export enum StreamError
```

**Variants:**

- `Ok` — No error, transition successful.
- `InvalidTransition` — Frame type not valid in current state.
- `StreamError` — Stream-level protocol error (RST_STREAM).
- `ConnectionError` — Connection-level error (GOAWAY).

<a id="WsParseResult"></a>

### WsParseResult

Import: `"http/parser"`.

```vex
export enum WsParseResult
```

**Variants:**

- `Ok` — Frame header parsed. WsFrame contains metadata.
- `NeedMore` — Need more data (at least needBytes more).
- `Error` — Protocol error.

<a id="asyncBodyPipelineNext"></a>

### asyncBodyPipelineNext

Import: `"http/fiber"`.

```vex
export fn asyncBodyPipelineNext(steps: Vec<AsyncBodyHandler>): AsyncBodyPipelineNext
```

**Returns:** `AsyncBodyPipelineNext`

<a id="asyncPipelineNext"></a>

### asyncPipelineNext

Import: `"http/fiber"`.

```vex
export fn asyncPipelineNext(steps: Vec<AsyncHandler>): AsyncPipelineNext
```

Move a finalized handler sequence into a task-owned continuation.

**Returns:** `AsyncPipelineNext`

<a id="cors"></a>

### cors

Import: `"http"`, `"http/middleware"`.

```vex
export fn cors(c: &Ctx!)
```

Default CORS middleware — allows all origins.

<a id="logger"></a>

### logger

Import: `"http"`, `"http/middleware"`.

```vex
export fn logger(c: &Ctx!)
```

Logger middleware — prints method, path, status, and latency.

<a id="detectBodyMode"></a>

### detectBodyMode

Import: `"http/parser"`.

```vex
export fn detectBodyMode(hdrs: &ParserHeaders, isRequest: bool): BodyMode
```

**Returns:** `BodyMode`

<a id="parseFiberRequestInto"></a>

### parseFiberRequestInto

Import: `"http/parser"`.

```vex
export fn parseFiberRequestInto(buf: str, out: &FiberParsedRequest!): FiberRequestResult
```

**Returns:** `FiberRequestResult`

<a id="parseFiberRequestIntoWithLimits"></a>

### parseFiberRequestIntoWithLimits

Import: `"http/parser"`.

```vex
export fn parseFiberRequestIntoWithLimits(buf: str, out: &FiberParsedRequest!, limits: FiberRequestLimits): FiberRequestResult
```

**Returns:** `FiberRequestResult`

<a id="parseFiberRequest"></a>

### parseFiberRequest

Import: `"http/parser"`.

```vex
export fn parseFiberRequest(buf: str): (FiberParsedRequest, FiberRequestResult)
```

**Returns:** `(FiberParsedRequest, FiberRequestResult)`

<a id="isKnownH2FrameType"></a>

### isKnownH2FrameType

Import: `"http/parser"`.

```vex
export fn isKnownH2FrameType(frameType: u8): bool
```

Whether this package assigns semantics to a frame type. Unknown extension

frames must be discarded without consulting the stream state machine.

**Returns:** `bool`

<a id="parseH2Frame"></a>

### parseH2Frame

Import: `"http/parser"`.

```vex
export fn parseH2Frame(data: str): H2ParseResult
```

Parse an HTTP/2 frame header (9 bytes).

Caller must then read frame.length bytes of payload.

**Returns:** `H2ParseResult`

<a id="parseH2FrameLimited"></a>

### parseH2FrameLimited

Import: `"http/parser"`.

```vex
export fn parseH2FrameLimited(data: str, maxFrameSize: u32): H2ParseResult
```

Parse a frame header under the peer's negotiated maximum frame size.

**Returns:** `H2ParseResult`

<a id="parseSettingsUpdate"></a>

### parseSettingsUpdate

Import: `"http/parser"`.

```vex
export fn parseSettingsUpdate(payload: str, current: &H2Settings): H2SettingsUpdateResult
```

Parse one SETTINGS delta against the currently effective values. Unknown

identifiers are ignored, duplicate identifiers are applied in wire order,
and omitted settings retain their previous values.

**Returns:** `H2SettingsUpdateResult`

<a id="parseSettings"></a>

### parseSettings

Import: `"http/parser"`.

```vex
export fn parseSettings(payload: str, settings: &H2Settings!): bool
```

Parse SETTINGS payload. Each setting is 6 bytes: id(16) + value(32).

**Returns:** `bool`

<a id="parseLegacyPriority"></a>

### parseLegacyPriority

Import: `"http/parser"`.

```vex
export fn parseLegacyPriority(payload: str): H2LegacyPriorityResult
```

Parse the exact five-byte deprecated PRIORITY payload. Stream

self-dependency is validated by the protocol owner because it needs the
frame's stream identifier.

**Returns:** `H2LegacyPriorityResult`

<a id="parseRstStream"></a>

### parseRstStream

Import: `"http/parser"`.

```vex
export fn parseRstStream(payload: str): H2RstStreamResult
```

Parse the exact four-byte RST_STREAM error code. Error codes are an open

32-bit space, so every value (including extension codes) is preserved.

**Returns:** `H2RstStreamResult`

<a id="parseWindowUpdate"></a>

### parseWindowUpdate

Import: `"http/parser"`.

```vex
export fn parseWindowUpdate(payload: str): H2WindowUpdateResult
```

Parse a complete WINDOW_UPDATE payload and reject the reserved zero

increment before it can reach flow-control arithmetic.

**Returns:** `H2WindowUpdateResult`

<a id="parseGoAway"></a>

### parseGoAway

Import: `"http/parser"`.

```vex
export fn parseGoAway(payload: str): H2GoAwayResult
```

Parse a complete GOAWAY payload. Truncated control frames fail closed.

**Returns:** `H2GoAwayResult`

<a id="encodeH2FrameHeader"></a>

### encodeH2FrameHeader

Import: `"http/parser"`.

```vex
export fn encodeH2FrameHeader(out: &str!, length: u32, frameType: u8, flags: u8, streamId: u32): H2EncodeResult
```

Encode an HTTP/2 frame header into `out` after validating the complete

metadata and destination capacity. Failed writes leave `out` unchanged.

**Returns:** `H2EncodeResult`

<a id="encodeSettingsPayload"></a>

### encodeSettingsPayload

Import: `"http/parser"`.

```vex
export fn encodeSettingsPayload(out: &str!, settings: &H2Settings): H2EncodeResult
```

Encode the six standard SETTINGS entries as a 36-byte payload.

**Returns:** `H2EncodeResult`

<a id="encodeSettingsFrame"></a>

### encodeSettingsFrame

Import: `"http/parser"`.

```vex
export fn encodeSettingsFrame(out: &str!, settings: &H2Settings): H2EncodeResult
```

Build a complete SETTINGS frame (9-byte header + 36-byte payload).

**Returns:** `H2EncodeResult`

<a id="encodeSettingsFrameSelected"></a>

### encodeSettingsFrameSelected

Import: `"http/parser"`.

```vex
export fn encodeSettingsFrameSelected(out: &str!, settings: &H2Settings, present: u8): H2EncodeResult
```

Encode only the selected standard SETTINGS entries. This is the canonical

transport API: roles can omit forbidden fields (servers must not emit
SETTINGS_ENABLE_PUSH), and unchanged defaults do not waste wire bytes.
Selection uses the `H2_SETTINGS_*` presence mask returned by
`parseSettingsUpdate`; unknown mask bits fail before output mutation.

**Returns:** `H2EncodeResult`

<a id="encodeSettingsAck"></a>

### encodeSettingsAck

Import: `"http/parser"`.

```vex
export fn encodeSettingsAck(out: &str!): H2EncodeResult
```

Build an empty SETTINGS acknowledgement frame.

**Returns:** `H2EncodeResult`

<a id="encodePing"></a>

### encodePing

Import: `"http/parser"`.

```vex
export fn encodePing(out: &str!, opaqueData: str, isAck: bool): H2EncodeResult
```

Build a PING frame. `opaqueData` must contain exactly eight bytes.

**Returns:** `H2EncodeResult`

<a id="encodeLegacyPriority"></a>

### encodeLegacyPriority

Import: `"http/parser"`.

```vex
export fn encodeLegacyPriority(out: &str!, streamId: u32, priority: &H2LegacyPriority): H2EncodeResult
```

Build one deprecated RFC 7540 PRIORITY compatibility frame. Vex-native

scheduling should emit RFC 9218 PRIORITY_UPDATE instead.

**Returns:** `H2EncodeResult`

<a id="encodeWindowUpdate"></a>

### encodeWindowUpdate

Import: `"http/parser"`.

```vex
export fn encodeWindowUpdate(out: &str!, streamId: u32, increment: u32): H2EncodeResult
```

Build a WINDOW_UPDATE frame.

**Returns:** `H2EncodeResult`

<a id="encodeRstStream"></a>

### encodeRstStream

Import: `"http/parser"`.

```vex
export fn encodeRstStream(out: &str!, streamId: u32, errorCode: u32): H2EncodeResult
```

Build a RST_STREAM frame.

**Returns:** `H2EncodeResult`

<a id="encodeGoAway"></a>

### encodeGoAway

Import: `"http/parser"`.

```vex
export fn encodeGoAway(out: &str!, lastStreamId: u32, errorCode: u32): H2EncodeResult
```

Build a GOAWAY frame.

**Returns:** `H2EncodeResult`

<a id="encodeGoAwayWithDebug"></a>

### encodeGoAwayWithDebug

Import: `"http/parser"`.

```vex
export fn encodeGoAwayWithDebug(out: &str!, lastStreamId: u32, errorCode: u32, debugData: str): H2EncodeResult
```

Build a complete GOAWAY frame including optional opaque diagnostic bytes.

Capacity and the 24-bit frame-length bound are validated before any write.

**Returns:** `H2EncodeResult`

<a id="validateH2FieldSection"></a>

### validateH2FieldSection

Import: `"http/parser"`.

```vex
export fn validateH2FieldSection(headers: &Vec<HpackHeader>, kind: H2FieldSectionKind): H2FieldSectionResult
```

Validate a complete decompressed field section according to RFC 9113's

generic field, pseudo-header, request, response and trailer rules.

**Returns:** `H2FieldSectionResult`

<a id="parseH2PriorityFieldWithLimit"></a>

### parseH2PriorityFieldWithLimit

Import: `"http/parser"`.

```vex
export fn parseH2PriorityFieldWithLimit(fieldValue: str, maximumBytes: usize): H2PriorityFieldResult
```

Parse the RFC 9218 Priority Dictionary without allocation. Unknown members

and known members with unsupported/out-of-range types are ignored exactly as
required; malformed Structured Fields syntax fails closed.

**Returns:** `H2PriorityFieldResult`

<a id="parseH2PriorityField"></a>

### parseH2PriorityField

Import: `"http/parser"`.

```vex
export fn parseH2PriorityField(fieldValue: str): H2PriorityFieldResult
```

**Returns:** `H2PriorityFieldResult`

<a id="parseH2PriorityUpdateWithLimit"></a>

### parseH2PriorityUpdateWithLimit

Import: `"http/parser"`.

```vex
export fn parseH2PriorityUpdateWithLimit(payload: str, maximumFieldBytes: usize): H2PriorityUpdateResult
```

Parse a complete HTTP/2 PRIORITY_UPDATE payload: 31-bit target stream ID

followed by one ASCII Structured Fields Dictionary.

**Returns:** `H2PriorityUpdateResult`

<a id="parseH2PriorityUpdate"></a>

### parseH2PriorityUpdate

Import: `"http/parser"`.

```vex
export fn parseH2PriorityUpdate(payload: str): H2PriorityUpdateResult
```

**Returns:** `H2PriorityUpdateResult`

<a id="encodeH2PriorityUpdate"></a>

### encodeH2PriorityUpdate

Import: `"http/parser"`.

```vex
export fn encodeH2PriorityUpdate(out: &str!, streamId: u32, priority: &H2Priority): H2EncodeResult
```

Encode a canonical complete PRIORITY_UPDATE frame. False incremental uses

its RFC default by omission; urgency is always explicit.

**Returns:** `H2EncodeResult`

<a id="advanceMessageFraming"></a>

### advanceMessageFraming

Import: `"http/parser"`.

```vex
export fn advanceMessageFraming(current: MessageFraming, name: str, value: str): MessageFraming
```

Apply one field to an in-progress framing decision.

The incremental Fiber parser and the fixed `ParserHeaders` parser both use
this transition, so an attacker cannot get a different body boundary by
choosing the server's fast parser instead of the canonical parser.

**Returns:** `MessageFraming`

<a id="isValidHostAuthority"></a>

### isValidHostAuthority

Import: `"http/parser"`.

```vex
export fn isValidHostAuthority(value: str): bool
```

Validate the HTTP `Host` field's authority *shape* without allocation.

This deliberately validates the interpretation boundary needed by an origin
server: no user-info, path, query, fragment, unbracketed IPv6 ambiguity, or
invalid decimal port can reach host-based middleware. Bracketed literals
use the URI `IPv6address` / `IPvFuture` grammar, while socket address-family
resolution remains the networking layer's responsibility. Both HTTP/1
parser front doors call this helper.

**Returns:** `bool`

<a id="parseHeaders"></a>

### parseHeaders

Import: `"http/parser"`.

```vex
export fn parseHeaders(sc: &Scanner!, hdrs: &ParserHeaders!): HeaderParseResult
```

Parse HTTP/1.1 headers from a scanner.

Expects scanner positioned at start of first header line.
Parses until \r\n\r\n (empty line).
Returns HeaderParseResult indicating outcome.
Format per RFC 7230:
field-name ":" OWS field-value OWS CRLF

**Returns:** `HeaderParseResult`

<a id="decodeIntegerChecked"></a>

### decodeIntegerChecked

Import: `"http/parser"`.

```vex
export fn decodeIntegerChecked(data: str, prefixBits: u8): HpackIntegerResult
```

Decode an HPACK integer while preserving truncation and overflow.

**Returns:** `HpackIntegerResult`

<a id="decodeInteger"></a>

### decodeInteger

Import: `"http/parser"`.

```vex
export fn decodeInteger(data: str, prefixBits: u8): (u64, usize)
```

Compatibility helper. Prefer `decodeIntegerChecked` in protocol code.

**Returns:** `(u64, usize)`

<a id="encodeInteger"></a>

### encodeInteger

Import: `"http/parser"`.

```vex
export fn encodeInteger(out: &str!, value: u64, prefixBits: u8, prefixByte: u8): usize
```

Encode an HPACK integer. Returns bytes written to `out`.

**Returns:** `usize`

<a id="decodeHeader"></a>

### decodeHeader

Import: `"http/parser"`.

```vex
export fn decodeHeader(data: str, table: &DynamicTable!): (HpackResult, usize)
```

Decode the next HPACK header representation from data.

Returns (HpackResult, bytesConsumed).

**Returns:** `(HpackResult, usize)`

<a id="decodeHeaderLimited"></a>

### decodeHeaderLimited

Import: `"http/parser"`.

```vex
export fn decodeHeaderLimited(data: str, table: &DynamicTable!, maxStringBytes: usize, maxDynamicTableSize: usize): (HpackResult, usize)
```

Decode one representation under explicit string and table bounds.

**Returns:** `(HpackResult, usize)`

<a id="decodeHeaderBlock"></a>

### decodeHeaderBlock

Import: `"http/parser"`.

```vex
export fn decodeHeaderBlock(data: str, table: &DynamicTable!): HpackBlockResult
```

Decode a complete HPACK header block.

Returns list of decoded headers.

**Returns:** `HpackBlockResult`

<a id="decodeHeaderBlockLimited"></a>

### decodeHeaderBlockLimited

Import: `"http/parser"`.

```vex
export fn decodeHeaderBlockLimited(data: str, table: &DynamicTable!, limits: &HpackDecodeLimits): HpackBlockResult
```

Decode a complete block or return a typed terminal error. Partial header

lists are never reported as success.

**Returns:** `HpackBlockResult`

<a id="encodeHeaderBlockLimited"></a>

### encodeHeaderBlockLimited

Import: `"http/parser"`.

```vex
export fn encodeHeaderBlockLimited(headers: &Vec<HpackHeader>, encoder: &HpackEncoder!, out: &str!, limits: &HpackEncodeLimits): HpackEncodeResult
```

Encode one complete HPACK field block transactionally. Every semantic and

capacity check runs before the first output write. The dynamic table and
pending SETTINGS update are committed only after encoding succeeds.

**Returns:** `HpackEncodeResult`

<a id="encodeHeaderBlock"></a>

### encodeHeaderBlock

Import: `"http/parser"`.

```vex
export fn encodeHeaderBlock(headers: &Vec<HpackHeader>, encoder: &HpackEncoder!, out: &str!): HpackEncodeResult
```

**Returns:** `HpackEncodeResult`

<a id="huffmanCode"></a>

### huffmanCode

Import: `"http/parser"`.

```vex
export fn huffmanCode(sym: u8): (u32, u8)
```

Get the HPACK Huffman code and bit length for a byte value (0..255).

O(1), branch-free table lookup.

**Returns:** `(u32, u8)`

<a id="huffmanEncodedLength"></a>

### huffmanEncodedLength

Import: `"http/parser"`.

```vex
export fn huffmanEncodedLength(input: str): usize
```

Calculate the encoded byte length of a string under HPACK Huffman.

Used to decide whether Huffman encoding saves space.

**Returns:** `usize`

<a id="huffmanEncode"></a>

### huffmanEncode

Import: `"http/parser"`.

```vex
export fn huffmanEncode(input: str, out: &str!): usize
```

Encode a string using HPACK Huffman coding.

Writes to `out` and returns the number of bytes written.
Output is padded with the EOS prefix (all 1-bits) to the next byte boundary,
as required by RFC 7541 section 5.2.

**Returns:** `usize`

<a id="huffmanDecode"></a>

### huffmanDecode

Import: `"http/parser"`.

```vex
export fn huffmanDecode(input: str, inputLen: usize, out: &str!, outputCapacity: usize): HuffDecodeResult
```

Decode HPACK Huffman-encoded bytes.

The decoder walks a compact canonical binary trie. Every input bit performs
exactly one transition-table lookup; terminal transitions emit one symbol and
reset to the root state.
Validation:
- EOS cannot occur in the encoded payload
- caller output capacity is enforced before every write
- terminal padding is at most 7 bits
- terminal padding must be an all-1 prefix of EOS

**Returns:** `HuffDecodeResult`

<a id="multipartBoundary"></a>

### multipartBoundary

Import: `"http"`, `"http/parser"`.

```vex
export fn multipartBoundary(contentType: str): Option<string>
```

Extract and own the boundary parameter from a multipart/form-data content

type. Quoted values support backslash escaping; duplicate or trailing junk
is rejected instead of selecting one ambiguous boundary.

**Returns:** `Option<string>`

<a id="multipartConsumer"></a>

### multipartConsumer

Import: `"http"`, `"http/parser"`.

```vex
export fn multipartConsumer<S>( boundary: str, limits: MultipartLimits, sink: &S!, ): Option<MultipartConsumer<S>> where S: MultipartSink
```

**Type Parameters:**

- `S`

**Where:**

- `MultipartSink`: `MultipartSink`

**Returns:** `Option<MultipartConsumer<S>>where S: MultipartSink`

<a id="parseRequest"></a>

### parseRequest

Import: `"http/parser"`.

```vex
export fn parseRequest(buf: str): (ParserRequest, RequestResult)
```

Parse an HTTP/1.1 request from buffer.

Returns (Request, RequestResult).
On Complete, the usize is the byte index where the body starts.
On Incomplete/Error, the Request may be partially filled.
Zero-copy: all str fields reference the input buffer.

**Returns:** `(ParserRequest, RequestResult)`

<a id="parseRequestBuffer"></a>

### parseRequestBuffer

Import: `"http/parser"`.

```vex
export fn parseRequestBuffer(buf: str): (ParserRequest, RequestResult)
```

Alias entrypoint to avoid name collision with `http/src/request.vx` parseRequest(fd).

**Returns:** `(ParserRequest, RequestResult)`

<a id="parseResponse"></a>

### parseResponse

Import: `"http/parser"`.

```vex
export fn parseResponse(buf: str): (Response, ResponseResult)
```

Parse an HTTP/1.1 response from buffer.

RFC 7230 status-line:
HTTP-version SP status-code SP reason-phrase CRLF
Returns (Response, ResponseResult).

**Returns:** `(Response, ResponseResult)`

<a id="eqCaseInsensitive"></a>

### eqCaseInsensitive

Import: `"http/parser"`.

```vex
export fn eqCaseInsensitive(a: str, target: str): bool
```

Case-insensitive ASCII comparison. Both inputs must have the same length;

neither side carries a hidden pre-normalization requirement.

**Returns:** `bool`

<a id="parseDecimal"></a>

### parseDecimal

Import: `"http/parser"`.

```vex
export fn parseDecimal(s: str): Option<i64>
```

Parse a decimal integer from a str view.

Returns Some(value) only when the entire view is decimal digits.
Overflow-safe for values ≤ i64.MAX.

**Returns:** `Option<i64>`

<a id="parseHex"></a>

### parseHex

Import: `"http/parser"`.

```vex
export fn parseHex(s: str): Option<i64>
```

Parse a hexadecimal integer from a str view (for chunked encoding).

Returns Some(value) only when the complete view is hexadecimal digits.
Case-insensitive A-F. Overflow-safe.

**Returns:** `Option<i64>`

<a id="parseFrame"></a>

### parseFrame

Import: `"http/parser"`.

```vex
export fn parseFrame(data: str): WsParseResult
```

Parse a WebSocket frame header from raw bytes.

Returns WsParseResult with frame info.
On Ok, frame.headerLen indicates where payload starts.
Caller must then read frame.payloadLen bytes of payload.

**Returns:** `WsParseResult`

<a id="applyMask"></a>

### applyMask

Import: `"http/parser"`.

```vex
export fn applyMask(payload: &str!, maskKey: u32, len: usize)
```

Apply/remove WebSocket mask to payload buffer (in-place).

XOR with 4-byte rotating mask key.
Uses RawBuf for safe byte-level access.

<a id="encodedFrameSize"></a>

### encodedFrameSize

Import: `"http/parser"`.

```vex
export fn encodedFrameSize(payloadLen: usize, masked: bool): usize
```

Calculate encoded frame size (header + payload).

**Returns:** `usize`

<a id="encodeFrameHeader"></a>

### encodeFrameHeader

Import: `"http/parser"`.

```vex
export fn encodeFrameHeader(out: &str!, fin: bool, opcode: u8, payloadLen: usize, masked: bool, maskKey: u32): usize
```

Encode a WebSocket frame header into `out` buffer.

Returns number of header bytes written.
Caller must write payload immediately after.

**Returns:** `usize`

<a id="parseRequest-2"></a>

### parseRequest

Import: `"http"`.

```vex
export fn parseRequest(fd: i64): Request
```

Read and parse an HTTP request from a TCP socket fd.

**Returns:** `Request`

<a id="respondText"></a>

### respondText

Import: `"http"`.

```vex
export fn respondText(fd: i64, text: string)
```

<a id="respondJSON"></a>

### respondJSON

Import: `"http"`.

```vex
export fn respondJSON(fd: i64, json: string)
```

<a id="respondError"></a>

### respondError

Import: `"http"`.

```vex
export fn respondError(fd: i64, code: i32, message: string)
```

<a id="respondRedirect"></a>

### respondRedirect

Import: `"http"`.

```vex
export fn respondRedirect(fd: i64, location: string)
```

<a id="writeDeadlineNs"></a>

### writeDeadlineNs

Import: `"http"`.

```vex
export fn writeDeadlineNs(timeoutMs: i32): u64
```

Compute one saturating monotonic deadline for a complete response drain.

Internal streaming paths call this once and reuse it for every chunk; a
slow peer therefore cannot reset the timeout by accepting one chunk at a
time.

**Returns:** `u64`

<a id="sendAllUntil"></a>

### sendAllUntil

Import: `"http"`.

```vex
export fn sendAllUntil(fd: i64, buf: Ptr<u8>, len: u64, deadlineNs: u64): i64
```

Drain bytes against a caller-owned absolute monotonic deadline.

This is the streaming primitive used by Fiber's multi-chunk paths. The
deadline applies to the entire response, not merely one `send()` retry.

**Returns:** `i64`

<a id="sendAllWithTimeout"></a>

### sendAllWithTimeout

Import: `"http"`.

```vex
export fn sendAllWithTimeout(fd: i64, buf: Ptr<u8>, len: u64, timeoutMs: i32): i64
```

Drain a socket without allowing a permanently backpressured peer to pin the

worker forever. Non-positive timeouts use the production default rather
than disabling the safety bound. Returns -110 when the monotonic deadline
expires.

**Returns:** `i64`

<a id="sendAll"></a>

### sendAll

Import: `"http"`.

```vex
export fn sendAll(fd: i64, buf: Ptr<u8>, len: u64): i64
```

Drain using HTTP's production default write deadline.

**Returns:** `i64`

<a id="statusText"></a>

### statusText

Import: `"http"`.

```vex
export fn statusText(code: i32): string
```

**Returns:** `string`

<a id="statusAllowsContent"></a>

### statusAllowsContent

Import: `"http"`.

```vex
export fn statusAllowsContent(code: i32): bool
```

Whether an HTTP response status permits a payload body on the wire.

`HEAD` is intentionally not handled here: it has the status semantics of
its corresponding `GET` response and therefore preserves the prospective
payload length while suppressing only the payload bytes. The response
serializer carries that request-specific distinction separately.

**Returns:** `bool`

<a id="webSocketUpgradeResponse"></a>

### webSocketUpgradeResponse

Import: `"http/ws"`.

```vex
export fn webSocketUpgradeResponse(req: &Request): Option<string>
```

Build the exact RFC 6455 `101 Switching Protocols` bytes after validation.

This is transport-neutral: blocking `WsConn` may write it immediately,
whereas Fiber queues it in its worker-owned non-blocking session.

**Returns:** `Option<string>`

<a id="webSocketUpgradeResponseWithProtocol"></a>

### webSocketUpgradeResponseWithProtocol

Import: `"http/ws"`.

```vex
export fn webSocketUpgradeResponseWithProtocol(req: &Request, protocol: str): Option<string>
```

Build a validated RFC 6455 upgrade response selecting one client-offered

subprotocol. An empty selection preserves the ordinary extension-free
handshake. A non-empty value must be one exact, case-sensitive HTTP token
from the request; a server cannot invent or rewrite a protocol name.

**Returns:** `Option<string>`

<a id="isWebSocketUpgrade"></a>

### isWebSocketUpgrade

Import: `"http/ws"`.

```vex
export fn isWebSocketUpgrade(req: &Request): bool
```

Check if a request is a WebSocket upgrade request.

**Returns:** `bool`

<a id="webSocketProtocolOffered"></a>

### webSocketProtocolOffered

Import: `"http/ws"`.

```vex
export fn webSocketProtocolOffered(req: &Request, protocol: str): bool
```

Test whether the validated opening request offered one exact subprotocol.

RFC 6455 subprotocol identifiers are case-sensitive; HTTP header-name
matching remains case-insensitive.

**Returns:** `bool`

<a id="HttpClientConfig-defaults"></a>

### HttpClientConfig.defaults

```vex
export fn HttpClientConfig.defaults(): HttpClientConfig
```

**Returns:** `HttpClientConfig`

<a id="HttpClient-new"></a>

### HttpClient.new

```vex
export fn HttpClient.new(): HttpClient
```

**Returns:** `HttpClient`

<a id="HttpClient-new-2"></a>

### HttpClient.new

```vex
export fn HttpClient.new(config: HttpClientConfig): HttpClient
```

**Returns:** `HttpClient`

<a id="HttpClient-config"></a>

### HttpClient.config

```vex
export fn (self: &HttpClient) config(): HttpClientConfig
```

**Returns:** `HttpClientConfig`

<a id="HttpRedirectPolicy-defaults"></a>

### HttpRedirectPolicy.defaults

```vex
export fn HttpRedirectPolicy.defaults(): HttpRedirectPolicy
```

**Returns:** `HttpRedirectPolicy`

<a id="HttpContentDecoding-defaults"></a>

### HttpContentDecoding.defaults

```vex
export fn HttpContentDecoding.defaults(): HttpContentDecoding
```

**Returns:** `HttpContentDecoding`

<a id="HttpRedirectResolver-resolve"></a>

### HttpRedirectResolver.resolve

```vex
async fn resolve( host: str, port: u16, context: &Context, ): Result<SocketAddr, IoError>;
```

This is the `resolve` requirement of `HttpRedirectResolver`, not a free function.

**Returns:** `Result<SocketAddr, IoError>;`

<a id="ClientResponseHead-header"></a>

### ClientResponseHead.header

```vex
export fn (self: &ClientResponseHead) header(name: str): string
```

Get a streamed response header (case-insensitive).

**Returns:** `string`

<a id="ClientResponseHead-ok"></a>

### ClientResponseHead.ok

```vex
export fn (self: &ClientResponseHead) ok(): bool
```

Check whether a streamed response has a 2xx status.

**Returns:** `bool`

<a id="ClientResponse-header"></a>

### ClientResponse.header

```vex
export fn (self: &ClientResponse) header(name: str): string
```

Get a response header (case-insensitive).

**Returns:** `string`

<a id="ClientResponse-ok"></a>

### ClientResponse.ok

```vex
export fn (self: &ClientResponse) ok(): bool
```

Check if response status is successful (2xx).

**Returns:** `bool`

<a id="ClientResponse-isRedirect"></a>

### ClientResponse.isRedirect

```vex
export fn (self: &ClientResponse) isRedirect(): bool
```

Check if response status is a redirect (3xx).

**Returns:** `bool`

<a id="ClientResponse-decodeContent"></a>

### ClientResponse.decodeContent

```vex
export fn (self: &ClientResponse!) decodeContent(decoding: &HttpContentDecoding): Result<(), IoError>
```

Decode the complete owning response body according to Content-Encoding.

Mutation is atomic: malformed/unsupported/oversized content leaves the
original response body and headers unchanged.

**Returns:** `Result<(), IoError>`

<a id="HttpSession-isReusable"></a>

### HttpSession.isReusable

```vex
export fn (self: &HttpSession) isReusable(): bool
```

True only while the exact connection is open and has completed a reusable

HTTP/1.1 response boundary.

**Returns:** `bool`

<a id="HttpSession-close"></a>

### HttpSession.close

```vex
export fn (self: &HttpSession!) close(): Result<(), IoError>
```

Explicitly close the session. Closing an already invalidated session is a

successful no-op.

**Returns:** `Result<(), IoError>`

<a id="HttpSession-drop"></a>

### HttpSession.drop

```vex
export fn (self: &HttpSession!) drop()
```

**Receiver:** `self: &HttpSession!` *(mutable reference)*

<a id="ClientRequest-new"></a>

### ClientRequest.new

```vex
export fn ClientRequest.new(method: str, host: str, path: str): ClientRequest
```

**Usage contract:** Construction does not connect or resolve DNS. Send-time validation rejects invalid authority, target and framing before opening a socket. See [client request construction](client.md#request-construction).

Creates a request for an HTTP authority. Direct-origin requests use

`/path?query`; `OPTIONS` may use `*`, while `CONNECT` uses authority-form.
The endpoint is supplied to `HttpClient.send` so the async request path
never performs hidden DNS.

**Returns:** `ClientRequest`

<a id="ClientRequest-setHeader"></a>

### ClientRequest.setHeader

```vex
export fn (self: &ClientRequest!) setHeader(name: str, value: str): &ClientRequest!
```

Set a request header. Authority/framing fields remain transport-owned and

are rejected at send time before a socket is opened.

**Returns:** `&ClientRequest!`

<a id="ClientRequest-setBody"></a>

### ClientRequest.setBody

```vex
export fn (self: &ClientRequest!) setBody(body: str): &ClientRequest!
```

Set a complete buffered request body.

**Returns:** `&ClientRequest!`

<a id="ClientRequest-setContentType"></a>

### ClientRequest.setContentType

```vex
export fn (self: &ClientRequest!) setContentType(contentType: str): &ClientRequest!
```

Set Content-Type for a buffered request body.

**Returns:** `&ClientRequest!`

<a id="ClientRequest-acceptCompressed"></a>

### ClientRequest.acceptCompressed

```vex
export fn (self: &ClientRequest!) acceptCompressed(): &ClientRequest!
```

Advertise exactly the pure-Vex content codings understood by

`ClientResponse.decodeContent`.

**Returns:** `&ClientRequest!`

<a id="HttpClient-connect"></a>

### HttpClient.connect

```vex
export async fn (self: &HttpClient) connect( endpoint: SocketAddr, context: &Context, ): Result<HttpSession, IoError>
```

Establish one exclusive reusable HTTP/1.1 session with this client's

configured resource policy. The endpoint is resolved by the caller; no DNS
work is hidden in this async path.

**Returns:** `Result<HttpSession, IoError>`

<a id="HttpSession-connect"></a>

### HttpSession.connect

```vex
export async fn HttpSession.connect( endpoint: SocketAddr, context: &Context, ): Result<HttpSession, IoError>
```

Establish one exclusive session using the default bounded client policy.

**Returns:** `Result<HttpSession, IoError>`

<a id="HttpSession-send"></a>

### HttpSession.send

```vex
export async fn (self: &HttpSession!) send( request: &ClientRequest, context: &Context, ): Result<ClientResponse, IoError>
```

Send one complete request over this session. A session is intentionally

sequential: calling `send` while another exchange is in flight fails with
`ResourceBusy` rather than allowing HTTP/1.1 response association to drift.

**Returns:** `Result<ClientResponse, IoError>`

<a id="HttpSession-sendInto"></a>

### HttpSession.sendInto

```vex
export async fn (self: &HttpSession!) sendInto<W>( request: &ClientRequest, destination: &W, context: &Context, ): Result<ClientResponseHead, IoError> where W: AsyncWriter
```

Session equivalent of `HttpClient.sendInto`. Decoded body bytes are

streamed into `destination`; the connection remains reusable only after a
fully framed HTTP/1.1 response reaches its terminal boundary.

**Type Parameters:**

- `W`

**Where:**

- `AsyncWriter`: `AsyncWriter`

**Returns:** `Result<ClientResponseHead, IoError>where W: AsyncWriter`

<a id="HttpSession-sendFrom"></a>

### HttpSession.sendFrom

```vex
export async fn (self: &HttpSession!) sendFrom<R>( request: &ClientRequest, source: &R!, contentLength: usize, context: &Context, ): Result<ClientResponse, IoError> where R: AsyncReader
```

Stream an exact-length request body over this exclusive keep-alive

session, then materialize the bounded response. The request's buffered body
must be empty; short source EOF, cancellation, source failure and socket
failure invalidate the session before it can re-enter a pool or caller loop.

**Type Parameters:**

- `R`

**Where:**

- `AsyncReader`: `AsyncReader`

**Returns:** `Result<ClientResponse, IoError>where R: AsyncReader`

<a id="HttpSession-sendFromInto"></a>

### HttpSession.sendFromInto

```vex
export async fn (self: &HttpSession!) sendFromInto<R, W>( request: &ClientRequest, source: &R!, contentLength: usize, destination: &W, context: &Context, ): Result<ClientResponseHead, IoError> where R: AsyncReader, W: AsyncWriter
```

Stream an exact-length request body and stream the decoded response body

into `destination` on the same exclusive session.

**Type Parameters:**

- `R`
- `W`

**Where:**

- `AsyncReader`: `AsyncReader`
- `AsyncWriter`: `AsyncWriter`

**Returns:** `Result<ClientResponseHead, IoError>where R: AsyncReader, W: AsyncWriter`

<a id="HttpClient-send"></a>

### HttpClient.send

```vex
export async fn (self: &HttpClient) send( request: &ClientRequest, endpoint: SocketAddr, context: &Context, ): Result<ClientResponse, IoError>
```

**Usage contract:** Performs one plaintext HTTP/1 exchange and returns independently owned headers/body. It does not follow redirects or decompress Content-Encoding automatically. HTTP error statuses can still be a successful transport result; inspect response.status or response.ok().

Sends one bounded HTTP/1.1 request to an already-resolved endpoint.

Cancellation and deadlines are forwarded through connect, complete write,
and every read; a canceled request never collapses into an invalid response
sentinel. The implementation closes its stream after one exchange until
connection-pool ownership and reuse proofs are available.

**Returns:** `Result<ClientResponse, IoError>`

<a id="HttpClient-sendFollowing"></a>

### HttpClient.sendFollowing

```vex
export async fn (self: &HttpClient) sendFollowing( request: &ClientRequest, endpoint: SocketAddr, redirectPolicy: &HttpRedirectPolicy, context: &Context, ): Result<ClientResponse, IoError>
```

Follow a finite chain of same-origin redirects for an owning buffered

request. Relative references are resolved with RFC 3986 semantics and the
original already-resolved endpoint is reused. A cross-origin Location
fails closed before opening another connection.

**Returns:** `Result<ClientResponse, IoError>`

<a id="HttpClient-sendFollowingResolved"></a>

### HttpClient.sendFollowingResolved

```vex
export async fn (self: &HttpClient) sendFollowingResolved<R>( request: &ClientRequest, endpoint: SocketAddr, redirectPolicy: &HttpRedirectPolicy, resolver: &R, context: &Context, ): Result<ClientResponse, IoError> where R: HttpRedirectResolver
```

Follow same- and cross-origin redirects through an explicit async endpoint

resolver. No DNS is hidden by the HTTP client. Cross-origin hops remove
Authorization, Proxy-Authorization and Cookie credentials before connect.

**Type Parameters:**

- `R`

**Where:**

- `HttpRedirectResolver`: `HttpRedirectResolver`

**Returns:** `Result<ClientResponse, IoError>where R: HttpRedirectResolver`

<a id="HttpClient-sendInto"></a>

### HttpClient.sendInto

```vex
export async fn (self: &HttpClient) sendInto<W>( request: &ClientRequest, endpoint: SocketAddr, destination: &W, context: &Context, ): Result<ClientResponseHead, IoError> where W: AsyncWriter
```

**Usage contract:** Removes HTTP transfer framing and writes each accepted prefix to the sink; Content-Encoding is not decompressed. Later failure does not roll back bytes already delivered. A successful head is returned only after the final body boundary; stage output when atomic publication is required.

Sends one bounded HTTP/1.1 request and streams its decoded final body into

`destination`. This is the allocation-bounded alternative to `send` for
downloads, proxying and protocol adapters: no response-sized `string` is
materialized. The TCP stream is intentionally closed after this exchange;
pooling and upgraded-connection ownership remain separate future APIs.

**Type Parameters:**

- `W`

**Where:**

- `AsyncWriter`: `AsyncWriter`

**Returns:** `Result<ClientResponseHead, IoError>where W: AsyncWriter`

<a id="HttpClient-sendFrom"></a>

### HttpClient.sendFrom

```vex
export async fn (self: &HttpClient) sendFrom<R>( request: &ClientRequest, endpoint: SocketAddr, source: &R!, contentLength: usize, context: &Context, ): Result<ClientResponse, IoError> where R: AsyncReader
```

Send one exact-length streaming request body and materialize the bounded

response. The stateless transport advertises `Connection: close`; callers
wanting proven sequential reuse should use `HttpSession.sendFrom`.

**Type Parameters:**

- `R`

**Where:**

- `AsyncReader`: `AsyncReader`

**Returns:** `Result<ClientResponse, IoError>where R: AsyncReader`

<a id="HttpClient-sendFromInto"></a>

### HttpClient.sendFromInto

```vex
export async fn (self: &HttpClient) sendFromInto<R, W>( request: &ClientRequest, endpoint: SocketAddr, source: &R!, contentLength: usize, destination: &W, context: &Context, ): Result<ClientResponseHead, IoError> where R: AsyncReader, W: AsyncWriter
```

Send one exact-length streaming request body and stream the decoded

response into `destination` without materializing either payload.

**Type Parameters:**

- `R`
- `W`

**Where:**

- `AsyncReader`: `AsyncReader`
- `AsyncWriter`: `AsyncWriter`

**Returns:** `Result<ClientResponseHead, IoError>where R: AsyncReader, W: AsyncWriter`

<a id="ClientRequest-send"></a>

### ClientRequest.send

```vex
export async fn (self: &ClientRequest) send( endpoint: SocketAddr, context: &Context, ): Result<ClientResponse, IoError>
```

Convenience overload for the default bounded client policy.

**Returns:** `Result<ClientResponse, IoError>`

<a id="ClientRequest-sendInto"></a>

### ClientRequest.sendInto

```vex
export async fn (self: &ClientRequest) sendInto<W>( endpoint: SocketAddr, destination: &W, context: &Context, ): Result<ClientResponseHead, IoError> where W: AsyncWriter
```

Convenience overload for a streamed response with default bounded policy.

**Type Parameters:**

- `W`

**Where:**

- `AsyncWriter`: `AsyncWriter`

**Returns:** `Result<ClientResponseHead, IoError>where W: AsyncWriter`

<a id="AppConfig-defaults"></a>

### AppConfig.defaults

```vex
export fn AppConfig.defaults(): AppConfig
```

**Returns:** `AppConfig`

<a id="App-new"></a>

### App.new

```vex
export fn App.new(): App<{HTTP_FULL}>
```

Create a new application with default config.

**Returns:** `App<{HTTP_FULL}>`

<a id="App-new-2"></a>

### App.new

```vex
export fn App.new(config: AppConfig): App<{HTTP_FULL}>
```

Create an application with one coherent resource/deadline policy.

**Returns:** `App<{HTTP_FULL}>`

<a id="App-new-3"></a>

### App.new

```vex
export fn App.new<const FEATURES: u32>(): App<{FEATURES}>
```

Create an exactly specialized application. Unknown bits and profiles

without HTTP/1 are rejected at compile time; no runtime configuration
branch is introduced.

**Type Parameters:**

- `const FEATURES: u32`

**Returns:** `App<{FEATURES}>`

<a id="App-new-4"></a>

### App.new

```vex
export fn App.new<const FEATURES: u32>(config: AppConfig): App<{FEATURES}>
```

**Type Parameters:**

- `const FEATURES: u32`

**Returns:** `App<{FEATURES}>`

<a id="App-get"></a>

### App.get

```vex
export fn (self: &App<FEATURES>!) get(path: string, handler: Handler)
```

<a id="App-getAsync"></a>

### App.getAsync

```vex
export fn (self: &App<FEATURES>!) getAsync(path: string, handler: AsyncHandler)
```

Register an explicit task-owned async route. It is a separate middleware

lane: synchronous `App.use` callbacks never cross an await boundary.
The initial transport policy closes after the response while descriptor
reattachment and pipelined-response ordering are still being proven.

<a id="App-postAsync"></a>

### App.postAsync

```vex
export fn (self: &App<FEATURES>!) postAsync(path: string, handler: AsyncHandler)
```

<a id="App-putAsync"></a>

### App.putAsync

```vex
export fn (self: &App<FEATURES>!) putAsync(path: string, handler: AsyncHandler)
```

<a id="App-deleteAsync"></a>

### App.deleteAsync

```vex
export fn (self: &App<FEATURES>!) deleteAsync(path: string, handler: AsyncHandler)
```

<a id="App-patchAsync"></a>

### App.patchAsync

```vex
export fn (self: &App<FEATURES>!) patchAsync(path: string, handler: AsyncHandler)
```

<a id="App-headAsync"></a>

### App.headAsync

```vex
export fn (self: &App<FEATURES>!) headAsync(path: string, handler: AsyncHandler)
```

<a id="App-optionsAsync"></a>

### App.optionsAsync

```vex
export fn (self: &App<FEATURES>!) optionsAsync(path: string, handler: AsyncHandler)
```

<a id="App-getAsyncWith"></a>

### App.getAsyncWith

```vex
export fn (self: &App<FEATURES>!) getAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

Route-local awaitable middleware. The final endpoint is appended exactly

once, preserving `before → await next() → after` in `AsyncPipelineNext`.

<a id="App-postAsyncWith"></a>

### App.postAsyncWith

```vex
export fn (self: &App<FEATURES>!) postAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-putAsyncWith"></a>

### App.putAsyncWith

```vex
export fn (self: &App<FEATURES>!) putAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-deleteAsyncWith"></a>

### App.deleteAsyncWith

```vex
export fn (self: &App<FEATURES>!) deleteAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-patchAsyncWith"></a>

### App.patchAsyncWith

```vex
export fn (self: &App<FEATURES>!) patchAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-headAsyncWith"></a>

### App.headAsyncWith

```vex
export fn (self: &App<FEATURES>!) headAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-optionsAsyncWith"></a>

### App.optionsAsyncWith

```vex
export fn (self: &App<FEATURES>!) optionsAsyncWith(path: string, middlewares: Vec<AsyncHandler>, handler: AsyncHandler)
```

<a id="App-bodyStream"></a>

### App.bodyStream

```vex
export fn (self: &App<FEATURES>!) bodyStream(method: str, path: string, handler: AsyncBodyHandler)
```

Register a task-owned, backpressured request-body stream. The handler calls

`await body.consume(consumer, context)`; decoded chunks never cross an
await as borrowed transport views and the connection closes after the
response until keep-alive reattachment is proven independently.

<a id="App-bodyStreamWith"></a>

### App.bodyStreamWith

```vex
export fn (self: &App<FEATURES>!) bodyStreamWith(method: str, path: string, middlewares: Vec<AsyncBodyHandler>, handler: AsyncBodyHandler)
```

<a id="App-getBodyStream"></a>

### App.getBodyStream

```vex
export fn (self: &App<FEATURES>!) getBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-postBodyStream"></a>

### App.postBodyStream

```vex
export fn (self: &App<FEATURES>!) postBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-putBodyStream"></a>

### App.putBodyStream

```vex
export fn (self: &App<FEATURES>!) putBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-deleteBodyStream"></a>

### App.deleteBodyStream

```vex
export fn (self: &App<FEATURES>!) deleteBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-patchBodyStream"></a>

### App.patchBodyStream

```vex
export fn (self: &App<FEATURES>!) patchBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-headBodyStream"></a>

### App.headBodyStream

```vex
export fn (self: &App<FEATURES>!) headBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-optionsBodyStream"></a>

### App.optionsBodyStream

```vex
export fn (self: &App<FEATURES>!) optionsBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="App-ws"></a>

### App.ws

```vex
export fn (self: &App<FEATURES>!) ws(path: string, handler: WsHandler)
```

Register a bounded, worker-owned WebSocket endpoint. The callback runs for

complete protocol messages only; `WsSession` queues outbound frames and is
drained through Fiber's non-blocking writable-interest path.

<a id="App-wsWithOptions"></a>

### App.wsWithOptions

```vex
export fn (self: &App<FEATURES>!) wsWithOptions(path: string, options: WsRouteOptions, handler: WsHandler)
```

Register a WebSocket endpoint with a startup-compiled subprotocol policy.

Server preference order is the order added to `WsRouteOptions`.

<a id="App-wsWithLifecycle"></a>

### App.wsWithLifecycle

```vex
export fn (self: &App<FEATURES>!) wsWithLifecycle(path: string, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

Register a WebSocket route with worker-owned lifecycle hooks. `onOpen`

runs only after the validated `101` is queued; `onClose` receives an opaque
session id when Fiber retires that connection for any terminal reason.

<a id="App-wsWithLifecycleOptions"></a>

### App.wsWithLifecycleOptions

```vex
export fn (self: &App<FEATURES>!) wsWithLifecycleOptions(path: string, options: WsRouteOptions, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

<a id="App-getStream"></a>

### App.getStream

```vex
export fn (self: &App<FEATURES>!) getStream(path: string, handler: StreamHandler)
```

Register a bounded dynamic HTTP/1 producer. Status and headers belong to

`Ctx` until `out.write` begins; body bytes then flow only through the
response-owned chunk framing writer.

<a id="App-postStream"></a>

### App.postStream

```vex
export fn (self: &App<FEATURES>!) postStream(path: string, handler: StreamHandler)
```

<a id="App-getStreamWith"></a>

### App.getStreamWith

```vex
export fn (self: &App<FEATURES>!) getStreamWith(path: string, middlewares: Vec<Handler>, handler: StreamHandler)
```

<a id="App-postStreamWith"></a>

### App.postStreamWith

```vex
export fn (self: &App<FEATURES>!) postStreamWith(path: string, middlewares: Vec<Handler>, handler: StreamHandler)
```

<a id="App-post"></a>

### App.post

```vex
export fn (self: &App<FEATURES>!) post(path: string, handler: Handler)
```

<a id="App-put"></a>

### App.put

```vex
export fn (self: &App<FEATURES>!) put(path: string, handler: Handler)
```

<a id="App-delete"></a>

### App.delete

```vex
export fn (self: &App<FEATURES>!) delete(path: string, handler: Handler)
```

<a id="App-patch"></a>

### App.patch

```vex
export fn (self: &App<FEATURES>!) patch(path: string, handler: Handler)
```

<a id="App-head"></a>

### App.head

```vex
export fn (self: &App<FEATURES>!) head(path: string, handler: Handler)
```

<a id="App-options"></a>

### App.options

```vex
export fn (self: &App<FEATURES>!) options(path: string, handler: Handler)
```

<a id="App-static"></a>

### App.static

```vex
export fn (self: &App<FEATURES>!) static(prefix: string, root: string)
```

Serve static files from a directory.

Registers a GET route on `prefix + "/*filepath"`; Router's standard HEAD
fallback selects the same representation without sending file bytes.

<a id="App-getWith"></a>

### App.getWith

```vex
export fn (self: &App<FEATURES>!) getWith(path: string, middlewares: Vec<Handler>, handler: Handler)
```

Register GET route with route-level middleware.

Middleware runs after global middleware, before the handler.
Example: app.getWith("/admin", myVec, adminHandler);

<a id="App-postWith"></a>

### App.postWith

```vex
export fn (self: &App<FEATURES>!) postWith(path: string, middlewares: Vec<Handler>, handler: Handler)
```

<a id="App-putWith"></a>

### App.putWith

```vex
export fn (self: &App<FEATURES>!) putWith(path: string, middlewares: Vec<Handler>, handler: Handler)
```

<a id="App-deleteWith"></a>

### App.deleteWith

```vex
export fn (self: &App<FEATURES>!) deleteWith(path: string, middlewares: Vec<Handler>, handler: Handler)
```

<a id="App-patchWith"></a>

### App.patchWith

```vex
export fn (self: &App<FEATURES>!) patchWith(path: string, middlewares: Vec<Handler>, handler: Handler)
```

<a id="App-all"></a>

### App.all

```vex
export fn (self: &App<FEATURES>!) all(path: string, handler: Handler)
```

<a id="App-group"></a>

### App.group

```vex
export fn (self: &App<FEATURES>!) group(prefix: string): Group<{FEATURES}>
```

Create a route group with a shared prefix.

Example: let! api = app.group("/api");
api.get("/users", handler);  // → GET /api/users

**Returns:** `Group<{FEATURES}>`

<a id="App-use"></a>

### App.use

```vex
export fn (self: &App<FEATURES>!) use(handler: Handler)
```

<a id="App-setNotFound"></a>

### App.setNotFound

```vex
export fn (self: &App<FEATURES>!) setNotFound(handler: Handler)
```

<a id="App-setErrorHandler"></a>

### App.setErrorHandler

```vex
export fn (self: &App<FEATURES>!) setErrorHandler(handler: Handler)
```

<a id="App-serveDirect"></a>

### App.serveDirect

```vex
export fn (self: App<FEATURES>) serveDirect(host: string, port: i32, handler: RequestHandler)
```

Serve one direct request callback through Fiber's production HTTP/1 path.

This is the canonical replacement for a separate low-level accept loop.
Use routes and middleware when an application needs routing semantics;
direct callbacks deliberately receive only the parsed request and response.

<a id="App-serveDirectWithContext"></a>

### App.serveDirectWithContext

```vex
export fn (self: App<FEATURES>) serveDirectWithContext(lifetime: Context, host: string, port: i32, handler: RequestHandler)
```

Context-cancellable direct callback variant. It has the same framing,

deadline, admission and lifecycle behavior as `listenWithContext`.

<a id="App-freeze"></a>

### App.freeze

```vex
export fn (self: &App<FEATURES>!) freeze()
```

Freeze the application: compile radix tree and snapshot middleware list.

Called automatically by listen(). After freeze(), no new routes or
middlewares can be added (they would be ignored at runtime).

**Receiver:** `self: &App<FEATURES>!` *(mutable reference)*

<a id="App-listen"></a>

### App.listen

```vex
export fn (self: App<FEATURES>) listen(host: string, port: i32)
```

Start the server. Blocks forever.

Linux:  N listen sockets with SO_REUSEPORT (kernel-level LB).
macOS:  Single acceptor thread + N workers via pipe-based FD distribution.
Eliminates kqueue thundering herd — guarantees even load spread.
Each worker owns its own event loop for independent I/O processing.

<a id="App-listenWithContext"></a>

### App.listenWithContext

```vex
export fn (self: App<FEATURES>) listenWithContext(lifetime: Context, host: string, port: i32)
```

Serve until `lifetime` is canceled or its deadline expires. Cancellation is

observed between event batches: an executing handler/pipeline completes,
new accepts stop, worker-owned connections close, and this call waits for
every spawned HTTP worker before returning.

<a id="App-dispatchBuffered"></a>

### App.dispatchBuffered

```vex
export fn (self: &App<FEATURES>) dispatchBuffered(ctx: &Ctx!): ApplicationDispatchResult
```

Dispatch a fully validated, buffered request without assuming a wire

protocol. `Ctx.res.buffered` is mandatory: handlers may call the ordinary
Fiber response API, but no socket write or protocol framing occurs here.
Dynamic transport lanes are returned before middleware or terminal user
code runs, allowing the owning event loop to install the correct stream.

**Returns:** `ApplicationDispatchResult`

<a id="AsyncBodyPipelineNext-run"></a>

### AsyncBodyPipelineNext.run

```vex
export async fn (self: &AsyncBodyPipelineNext!) run( ctx: &Ctx!, body: &AsyncRequestBody!, context: &Context, )
```

Monotonic body-route continuation. Advancing before awaiting prevents a

buggy middleware from replaying the endpoint with a second `next.run`.

<a id="AsyncRequestBody-new"></a>

### AsyncRequestBody.new

```vex
export fn AsyncRequestBody.new(stream: TcpStream, mode: BodyMode, initialBytes: str, maxBodyBytes: usize): Option<AsyncRequestBody>
```

Construct the task-owned body after Socket -&gt; TcpStream adoption. Initial

bytes are the exact suffix following the complete HTTP/1 header block and
may contain body framing plus a later pipelined request. The canonical body
reader preserves that suffix; the initial safe transport policy closes the
connection instead of attempting unproven worker reattachment.

**Returns:** `Option<AsyncRequestBody>`

<a id="AsyncRequestBody-consume"></a>

### AsyncRequestBody.consume

```vex
export async fn (self: &AsyncRequestBody!) consume<C>( consumer: &C!, context: &Context, ): Result<usize, IoError> where C: RequestBodyConsumer
```

Decode the complete bounded body into one route-owned consumer. Socket

reads park only this coroutine and use the supplied Context for cancellation
and deadlines. `Ok(total)` means `finish(total)` ran exactly once.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `Result<usize, IoError>where C: RequestBodyConsumer`

<a id="AsyncRequestBody-writeResponse"></a>

### AsyncRequestBody.writeResponse

```vex
export async fn (self: &AsyncRequestBody!) writeResponse( encoded: str, context: &Context, ): Result<(), IoError>
```

Fiber transport finalization. Kept on the body owner so the descriptor can

never be wrapped by a second writer after handoff.

**Returns:** `Result<(), IoError>`

<a id="AsyncRequestBody-close"></a>

### AsyncRequestBody.close

```vex
export fn (self: &AsyncRequestBody!) close(): Result<(), IoError>
```

**Returns:** `Result<(), IoError>`

<a id="AsyncRequestBody-isReusable"></a>

### AsyncRequestBody.isReusable

```vex
export fn (self: &AsyncRequestBody) isReusable(): bool
```

A streamed connection is reusable only after the canonical lifecycle has

positively completed. `NoBody` may remain idle because its boundary is
already known at header completion; cancelled/rejected consumers never
become reusable even when their reader happened to reach `done` first.

**Returns:** `bool`

<a id="AsyncPipelineNext-run"></a>

### AsyncPipelineNext.run

```vex
export async fn (self: &AsyncPipelineNext!) run(ctx: &Ctx!, context: &Context)
```

Resume the next handler in order. The cursor is advanced before the await,

so a handler cannot invoke the same successor twice. Calling `run` after
the terminal handler is a harmless no-op.

<a id="ConnBuf-new"></a>

### ConnBuf.new

```vex
export fn ConnBuf.new(): ConnBuf
```

Create a new connection buffer with default capacity.

reserve() + push loop — no reallocation during init.

**Returns:** `ConnBuf`

<a id="ConnBuf-pending"></a>

### ConnBuf.pending

```vex
export fn (self: &ConnBuf) pending(): usize
```

Number of unprocessed bytes available.

**Returns:** `usize`

<a id="ConnBuf-writePtr"></a>

### ConnBuf.writePtr

```vex
export fn (self: &ConnBuf!) writePtr(): Ptr<u8!>
```

Pointer to the start of free space (where recv should write).

**Returns:** `Ptr<u8!>`

<a id="ConnBuf-freeSpace"></a>

### ConnBuf.freeSpace

```vex
export fn (self: &ConnBuf) freeSpace(): usize
```

Amount of free space available for recv().

**Returns:** `usize`

<a id="ConnBuf-advance"></a>

### ConnBuf.advance

```vex
export fn (self: &ConnBuf!) advance(n: usize)
```

Advance write position after a successful recv().

<a id="ConnBuf-readPtr"></a>

### ConnBuf.readPtr

```vex
export fn (self: &ConnBuf) readPtr(): Ptr<u8>
```

Pointer to start of unprocessed data.

**Returns:** `Ptr<u8>`

<a id="ConnBuf-consume"></a>

### ConnBuf.consume

```vex
export fn (self: &ConnBuf!) consume(n: usize)
```

Consume `n` bytes from the front (after processing).

<a id="ConnBuf-compact"></a>

### ConnBuf.compact

```vex
export fn (self: &ConnBuf!) compact()
```

Move unprocessed data to front of buffer to free space at the end.

Uses RawBuf.copyTo (memmove) instead of byte-by-byte loop — ~10x faster.

**Receiver:** `self: &ConnBuf!` *(mutable reference)*

<a id="ConnBuf-grow"></a>

### ConnBuf.grow

```vex
export fn (self: &ConnBuf!) grow(): bool
```

Grow buffer capacity (doubles up to MAX_BUF). Returns false if at limit.

reserve() + push(0) loop — at most O(log N) reallocations total.

**Returns:** `bool`

<a id="ConnBuf-reset"></a>

### ConnBuf.reset

```vex
export fn (self: &ConnBuf!) reset()
```

Reset for keep-alive reuse (zero alloc — just resets cursors).

**Receiver:** `self: &ConnBuf!` *(mutable reference)*

<a id="Connection-new"></a>

### Connection.new

```vex
export fn Connection.new(fd: i32): Connection
```

**Returns:** `Connection`

<a id="Connection-recv"></a>

### Connection.recv

```vex
export fn (self: &Connection!) recv(): i64
```

Read from socket into buffer. Returns bytes read (0=EOF, &lt;0=error/EAGAIN).

**Returns:** `i64`

<a id="Connection-findHeaderEnd"></a>

### Connection.findHeaderEnd

```vex
export fn (self: &Connection!) findHeaderEnd(): i32
```

Check if a complete HTTP header block is available.

Scans for \r\n\r\n in the unprocessed region using SIMD acceleration.
Returns the offset (relative to readPos) of the first byte after \r\n\r\n,
or -1 if not yet complete.

**Returns:** `i32`

<a id="Connection-reset"></a>

### Connection.reset

```vex
export fn (self: &Connection!) reset()
```

Reset connection for keep-alive reuse.

**Receiver:** `self: &Connection!` *(mutable reference)*

<a id="Connection-consumeRequest"></a>

### Connection.consumeRequest

```vex
export fn (self: &Connection!) consumeRequest(total_len: usize)
```

Consume processed bytes (header + body).

<a id="ResponseStreamWriter-new"></a>

### ResponseStreamWriter.new

```vex
export fn ResponseStreamWriter.new(): ResponseStreamWriter
```

**Returns:** `ResponseStreamWriter`

<a id="ResponseStreamWriter-write"></a>

### ResponseStreamWriter.write

```vex
export fn (self: &ResponseStreamWriter!) write(data: str): bool
```

Write a bounded sequence of HTTP/1 chunks. Large producer strings are

segmented without a temporary copy; a zero-length write is intentionally a
no-op because only `finish` may send the terminal zero chunk.

**Returns:** `bool`

<a id="Ctx-new"></a>

### Ctx.new

```vex
export fn Ctx.new(req: Request): Ctx
```

Create a new Ctx from a parsed request.

req.query is str (Copy) — .clone() is a no-op, removed for perf.

**Returns:** `Ctx`

<a id="Ctx-empty"></a>

### Ctx.empty

```vex
export fn Ctx.empty(): Ctx
```

Create an empty Ctx for pre-allocation (zero alloc reuse pattern).

Fields are populated by handleRequest via reset() + direct assignment.

**Returns:** `Ctx`

<a id="Ctx-emptyHttp1Sync"></a>

### Ctx.emptyHttp1Sync

```vex
export fn Ctx.emptyHttp1Sync(): Ctx
```

Zero-capacity dynamic transport storage for the capability-sealed H1

profile. The public `Ctx` handler ABI stays stable, but construction does
not make response-stream machinery reachable or reserve its write buffer.

**Returns:** `Ctx`

<a id="Ctx-reset"></a>

### Ctx.reset

```vex
export fn (self: &Ctx!) reset()
```

Reset Ctx for reuse — clears all Vecs keeping capacity (zero alloc after warmup).

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-resetHttp1Sync"></a>

### Ctx.resetHttp1Sync

```vex
export fn (self: &Ctx!) resetHttp1Sync()
```

Reset only state reachable from the H1-sync capability surface. Dynamic

transport fields remain permanently disabled and therefore require no
per-request work or codegen closure.

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-method"></a>

### Ctx.method

```vex
export fn (self: &Ctx) method(): str
```

HTTP method (GET, POST, PUT, DELETE, etc.)

**Returns:** `str`

<a id="Ctx-path"></a>

### Ctx.path

```vex
export fn (self: &Ctx) path(): str
```

Request path (without query string).

**Returns:** `str`

<a id="Ctx-params"></a>

### Ctx.params

```vex
export fn (self: &Ctx) params(key: str): string
```

Get route parameter by name (from :param patterns).

**Returns:** `string`

<a id="Ctx-param"></a>

### Ctx.param

```vex
export fn (self: &Ctx) param(key: str): str
```

Borrowed route parameter view. The result is valid for this request.

Prefer this on hot paths when ownership is not required.

**Returns:** `str`

<a id="Ctx-query"></a>

### Ctx.query

```vex
export fn (self: &Ctx) query(key: str): string
```

Get query parameter by name.

**Returns:** `string`

<a id="Ctx-queryView"></a>

### Ctx.queryView

```vex
export fn (self: &Ctx) queryView(key: str): str
```

Borrowed raw query parameter view. Percent/form decoding is intentionally

separate because decoded bytes may require owned storage.

**Returns:** `str`

<a id="Ctx-indexQuery"></a>

### Ctx.indexQuery

```vex
export fn (self: &Ctx!) indexQuery()
```

Re-index the raw query after assigning Request.query.

Reuses the Vec capacity retained by reset(), so steady-state requests do
not allocate for ordinary query pairs.

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-header"></a>

### Ctx.header

```vex
export fn (self: &Ctx) header(name: str): str
```

Get request header by name (case-insensitive).

**Returns:** `str`

<a id="Ctx-body"></a>

### Ctx.body

```vex
export fn (self: &Ctx) body(): str
```

Raw request body.

**Returns:** `str`

<a id="Ctx-contentType"></a>

### Ctx.contentType

```vex
export fn (self: &Ctx) contentType(): str
```

Request Content-Type.

**Returns:** `str`

<a id="Ctx-isJSON"></a>

### Ctx.isJSON

```vex
export fn (self: &Ctx) isJSON(): bool
```

Check if request is JSON.

**Returns:** `bool`

<a id="Ctx-contentLength"></a>

### Ctx.contentLength

```vex
export fn (self: &Ctx) contentLength(): i64
```

Content-Length value (-1 if not present).

**Returns:** `i64`

<a id="Ctx-protocol"></a>

### Ctx.protocol

```vex
export fn (self: &Ctx) protocol(): str
```

HTTP version string (e.g. "HTTP/1.1", "HTTP/2").

**Returns:** `str`

<a id="Ctx-scheme"></a>

### Ctx.scheme

```vex
export fn (self: &Ctx) scheme(): str
```

URI scheme supplied by the transport protocol.

**Returns:** `str`

<a id="Ctx-authority"></a>

### Ctx.authority

```vex
export fn (self: &Ctx) authority(): str
```

Canonical request authority. HTTP/2 uses `:authority`; HTTP/1 falls back

to the validated Host field.

**Returns:** `str`

<a id="Ctx-originalURL"></a>

### Ctx.originalURL

```vex
export fn (self: &Ctx) originalURL(): string
```

Full original URL (path + query string). Returns owned string.

**Returns:** `string`

<a id="Ctx-baseURL"></a>

### Ctx.baseURL

```vex
export fn (self: &Ctx) baseURL(): string
```

Base URL (scheme + host). Derives from Host header.

**Returns:** `string`

<a id="Ctx-hostname"></a>

### Ctx.hostname

```vex
export fn (self: &Ctx) hostname(): str
```

Hostname from Host header (without port).

**Returns:** `str`

<a id="Ctx-ip"></a>

### Ctx.ip

```vex
export fn (self: &Ctx) ip(): str
```

Client IP address from X-Forwarded-For or X-Real-IP headers.

Falls back to empty str if neither header is set.

**Returns:** `str`

<a id="Ctx-userAgent"></a>

### Ctx.userAgent

```vex
export fn (self: &Ctx) userAgent(): str
```

User-Agent header.

**Returns:** `str`

<a id="Ctx-get"></a>

### Ctx.get

```vex
export fn (self: &Ctx) get(name: str): str
```

Get request header by name (alias for header(), Fiber v3 compat).

**Returns:** `str`

<a id="Ctx-xhr"></a>

### Ctx.xhr

```vex
export fn (self: &Ctx) xhr(): bool
```

Check if request is XMLHttpRequest (AJAX).

**Returns:** `bool`

<a id="Ctx-accepts"></a>

### Ctx.accepts

```vex
export fn (self: &Ctx) accepts(contentType: str): bool
```

Check if the request accepts a given content type.

**Returns:** `bool`

<a id="Ctx-cookies"></a>

### Ctx.cookies

```vex
export fn (self: &Ctx!) cookies(name: string): string
```

Get a cookie value by name from the request.

Parses the Cookie header lazily on first call; subsequent calls use the cache.

**Returns:** `string`

<a id="Ctx-setCookie"></a>

### Ctx.setCookie

```vex
export fn (self: &Ctx!) setCookie(cookie: Cookie)
```

Set a cookie on the response (adds Set-Cookie header).

<a id="Ctx-setSimpleCookie"></a>

### Ctx.setSimpleCookie

```vex
export fn (self: &Ctx!) setSimpleCookie(name: string, value: string, maxAge: i32)
```

Set a simple cookie by name, value, and max-age in seconds (HttpOnly).

<a id="Ctx-clearCookie"></a>

### Ctx.clearCookie

```vex
export fn (self: &Ctx!) clearCookie(name: string)
```

Delete a cookie by name (Max-Age=0).

<a id="Ctx-status"></a>

### Ctx.status

```vex
export fn (self: &Ctx!) status(code: i32): &Ctx!
```

Set response status code (chainable).

**Returns:** `&Ctx!`

<a id="Ctx-setType"></a>

### Ctx.setType

```vex
export fn (self: &Ctx!) setType(ct: string): &Ctx!
```

Set response Content-Type (chainable).

**Returns:** `&Ctx!`

<a id="Ctx-set"></a>

### Ctx.set

```vex
export fn (self: &Ctx!) set(name: string, value: string): &Ctx!
```

Set a response header (chainable).

**Returns:** `&Ctx!`

<a id="Ctx-sendString"></a>

### Ctx.sendString

```vex
export fn (self: &Ctx!) sendString(text: string)
```

Send a plain text response.

<a id="Ctx-sendJSON"></a>

### Ctx.sendJSON

```vex
export fn (self: &Ctx!) sendJSON(json: string)
```

**Usage contract:** Sets the JSON response body through the context-owned response. Use serde/json to serialize application data; concatenating arbitrary text here does not create valid JSON. Fiber owns the eventual wire flush.

Send a JSON string response.

<a id="Ctx-sendHTML"></a>

### Ctx.sendHTML

```vex
export fn (self: &Ctx!) sendHTML(html: string)
```

Send an HTML response.

<a id="Ctx-send"></a>

### Ctx.send

```vex
export fn (self: &Ctx!) send()
```

Send the response with current body/status.

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-sendStatus"></a>

### Ctx.sendStatus

```vex
export fn (self: &Ctx!) sendStatus(code: i32)
```

Send an empty response (status + headers only).

<a id="Ctx-redirect"></a>

### Ctx.redirect

```vex
export fn (self: &Ctx!) redirect(url: string)
```

Redirect to a URL (302 by default).

<a id="Ctx-redirectWithStatus"></a>

### Ctx.redirectWithStatus

```vex
export fn (self: &Ctx!) redirectWithStatus(url: string, code: i32)
```

Redirect with a specific status code (301, 302, 307, 308).

<a id="Ctx-location"></a>

### Ctx.location

```vex
export fn (self: &Ctx!) location(path: string): &Ctx!
```

Set Location header only (no redirect status).

**Returns:** `&Ctx!`

<a id="Ctx-download"></a>

### Ctx.download

```vex
export fn (self: &Ctx!) download(body: string, filename: string)
```

Set Content-Disposition for file download.

Sends the body with attachment headers so the browser triggers a download.

<a id="Ctx-setContentType"></a>

### Ctx.setContentType

```vex
export fn (self: &Ctx!) setContentType(ext: string): &Ctx!
```

Set Content-Type based on file extension.

**Returns:** `&Ctx!`

<a id="Ctx-sendFile"></a>

### Ctx.sendFile

```vex
export fn (self: &Ctx!) sendFile(filePath: string)
```

Serve a file from the filesystem.

Automatically detects Content-Type and handles error codes.

<a id="Ctx-sendStaticFile"></a>

### Ctx.sendStaticFile

```vex
export fn (self: &Ctx!) sendStaticFile(root: str, relative: str)
```

Serve one file that must remain below a configured static root.

Both the configured root and resolved candidate are canonicalized before
the file is opened. This rejects `..`, absolute-path tricks and symlinks
that point outside the published tree; checking the lexical request path
alone cannot provide that guarantee.
This is deliberately the only path used by `App.static` and `Group.static`.
The opened descriptor is retained until Fiber drains the response. This
preserves canonical-path security across the open/send boundary and streams
through the worker's bounded scratch buffer instead of materializing the
whole asset as a string.

<a id="Ctx-next"></a>

### Ctx.next

```vex
export fn (self: &Ctx!) next()
```

Continue to the next handler in the middleware chain.

This is the core of Fiber v3's middleware model.

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-runHandlerChain"></a>

### Ctx.runHandlerChain

```vex
export fn (self: &Ctx!) runHandlerChain()
```

Start the prepared middleware/handler chain at its first entry.

Middleware controls continuation exclusively through `next()`.

**Receiver:** `self: &Ctx!` *(mutable reference)*

<a id="Ctx-setLocal"></a>

### Ctx.setLocal

```vex
export fn (self: &Ctx!) setLocal(key: string, value: string)
```

Set a local value (for passing data between middlewares).

<a id="Ctx-getLocal"></a>

### Ctx.getLocal

```vex
export fn (self: &Ctx) getLocal(key: string): string
```

Get a local value set by a previous middleware.

**Returns:** `string`

<a id="Ctx-bodyJSON"></a>

### Ctx.bodyJSON

```vex
export fn (self: &Ctx) bodyJSON(key: string): string
```

Get a value from a JSON body by key (simple top-level string extraction).

Returns the string value for the key, or empty string if not found.
Note: This is a lightweight parser for {"key":"value"} patterns.
For nested JSON, use a dedicated JSON library.

**Returns:** `string`

<a id="Ctx-formValue"></a>

### Ctx.formValue

```vex
export fn (self: &Ctx) formValue(key: str): string
```

Get a form value from application/x-www-form-urlencoded body.

**Returns:** `string`

<a id="Group-get"></a>

### Group.get

```vex
export fn (self: &Group<FEATURES>!) get(path: string, handler: Handler)
```

<a id="Group-post"></a>

### Group.post

```vex
export fn (self: &Group<FEATURES>!) post(path: string, handler: Handler)
```

<a id="Group-getStream"></a>

### Group.getStream

```vex
export fn (self: &Group<FEATURES>!) getStream(path: string, handler: StreamHandler)
```

<a id="Group-postStream"></a>

### Group.postStream

```vex
export fn (self: &Group<FEATURES>!) postStream(path: string, handler: StreamHandler)
```

<a id="Group-bodyStream"></a>

### Group.bodyStream

```vex
export fn (self: &Group<FEATURES>!) bodyStream(method: str, path: string, handler: AsyncBodyHandler)
```

<a id="Group-getBodyStream"></a>

### Group.getBodyStream

```vex
export fn (self: &Group<FEATURES>!) getBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="Group-postBodyStream"></a>

### Group.postBodyStream

```vex
export fn (self: &Group<FEATURES>!) postBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="Group-putBodyStream"></a>

### Group.putBodyStream

```vex
export fn (self: &Group<FEATURES>!) putBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="Group-deleteBodyStream"></a>

### Group.deleteBodyStream

```vex
export fn (self: &Group<FEATURES>!) deleteBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="Group-patchBodyStream"></a>

### Group.patchBodyStream

```vex
export fn (self: &Group<FEATURES>!) patchBodyStream(path: string, handler: AsyncBodyHandler)
```

<a id="Group-ws"></a>

### Group.ws

```vex
export fn (self: &Group<FEATURES>!) ws(path: string, handler: WsHandler)
```

Register a WebSocket endpoint under this group's path and middleware

boundary. Its callback is invoked only after the worker has completed the
non-blocking HTTP upgrade handoff.

<a id="Group-wsWithOptions"></a>

### Group.wsWithOptions

```vex
export fn (self: &Group<FEATURES>!) wsWithOptions(path: string, options: WsRouteOptions, handler: WsHandler)
```

<a id="Group-wsWithLifecycle"></a>

### Group.wsWithLifecycle

```vex
export fn (self: &Group<FEATURES>!) wsWithLifecycle(path: string, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

Register WebSocket callbacks for open/message/close while preserving this

group's middleware boundary and prefix.

<a id="Group-wsWithLifecycleOptions"></a>

### Group.wsWithLifecycleOptions

```vex
export fn (self: &Group<FEATURES>!) wsWithLifecycleOptions(path: string, options: WsRouteOptions, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

<a id="Group-put"></a>

### Group.put

```vex
export fn (self: &Group<FEATURES>!) put(path: string, handler: Handler)
```

<a id="Group-delete"></a>

### Group.delete

```vex
export fn (self: &Group<FEATURES>!) delete(path: string, handler: Handler)
```

<a id="Group-patch"></a>

### Group.patch

```vex
export fn (self: &Group<FEATURES>!) patch(path: string, handler: Handler)
```

<a id="Group-head"></a>

### Group.head

```vex
export fn (self: &Group<FEATURES>!) head(path: string, handler: Handler)
```

<a id="Group-options"></a>

### Group.options

```vex
export fn (self: &Group<FEATURES>!) options(path: string, handler: Handler)
```

<a id="Group-static"></a>

### Group.static

```vex
export fn (self: &Group<FEATURES>!) static(prefix: string, root: string)
```

Serve static files from a directory under this group.

Registers a GET route on `groupPrefix + prefix + "/*filepath"`; Router's
standard HEAD fallback selects the same representation without file bytes.

<a id="Group-all"></a>

### Group.all

```vex
export fn (self: &Group<FEATURES>!) all(path: string, handler: Handler)
```

<a id="Group-use"></a>

### Group.use

```vex
export fn (self: &Group<FEATURES>!) use(handler: Handler)
```

<a id="Group-useBodyAsync"></a>

### Group.useBodyAsync

```vex
export fn (self: &Group<FEATURES>!) useBodyAsync(handler: AsyncBodyHandler)
```

Add middleware to this group's explicit request-body coroutine lane.

Synchronous `use` middleware deliberately remains worker-local and is not
smuggled across the descriptor handoff.

<a id="Group-group"></a>

### Group.group

```vex
export fn (self: &Group<FEATURES>!) group(subPrefix: string): Group<{FEATURES}>
```

Create a sub-group with an additional prefix.

**Returns:** `Group<{FEATURES}>`

<a id="RadixTree-empty"></a>

### RadixTree.empty

```vex
export fn RadixTree.empty(): RadixTree
```

Construct storage without allocating a root node. Router freeze uses this

for method slots which have no registered routes; the first insertion
materializes the root. Ordinary callers receive an initialized tree from
`new()`.

**Returns:** `RadixTree`

<a id="RadixTree-new"></a>

### RadixTree.new

```vex
export fn RadixTree.new(): RadixTree
```

**Returns:** `RadixTree`

<a id="RadixTree-insert"></a>

### RadixTree.insert

```vex
export fn (self: &RadixTree!) insert(pattern: string, handler: Handler)
```

<a id="RadixTree-insertWithMiddleware"></a>

### RadixTree.insertWithMiddleware

```vex
export fn (self: &RadixTree!) insertWithMiddleware(pattern: string, handler: Handler, middlewares: Vec<Handler>)
```

<a id="RadixTree-insertRoute"></a>

### RadixTree.insertRoute

```vex
export fn (self: &RadixTree!) insertRoute(pattern: string, handler: Handler, routeIndex: i32)
```

Insert a route while retaining the Router table index used to restore

route metadata after a hot-path match.

<a id="RadixTree-insertRouteWithMiddleware"></a>

### RadixTree.insertRouteWithMiddleware

```vex
export fn (self: &RadixTree!) insertRouteWithMiddleware(pattern: string, handler: Handler, middlewares: Vec<Handler>, routeIndex: i32)
```

<a id="RadixTree-findInto"></a>

### RadixTree.findInto

```vex
export fn (self: &RadixTree) findInto(path: str, ctx: &Ctx!): RadixMatch
```

Match directly into reusable request context buffers. No MatchResult,

parameter strings, or middleware Vec is allocated on the request path.

**Returns:** `RadixMatch`

<a id="RadixTree-find"></a>

### RadixTree.find

```vex
export fn (self: &RadixTree) find(path: str): MatchResult
```

**Returns:** `MatchResult`

<a id="WsRouteOptions-new"></a>

### WsRouteOptions.new

```vex
export fn WsRouteOptions.new(): WsRouteOptions
```

**Returns:** `WsRouteOptions`

<a id="WsRouteOptions-protocol"></a>

### WsRouteOptions.protocol

```vex
export fn (self: &WsRouteOptions!) protocol(value: string): &WsRouteOptions!
```

Add one case-sensitive RFC 6455 subprotocol in server preference order.

Invalid or duplicate startup configuration is a programmer error rather
than a silently unreachable production route.

**Returns:** `&WsRouteOptions!`

<a id="WsRouteOptions-requireSubprotocol"></a>

### WsRouteOptions.requireSubprotocol

```vex
export fn (self: &WsRouteOptions!) requireSubprotocol(): &WsRouteOptions!
```

Reject an opening handshake when it offers none of this route's supported

protocols. Without this flag, a valid no-overlap request upgrades without
a `Sec-WebSocket-Protocol` response, as RFC 6455 permits.

**Returns:** `&WsRouteOptions!`

<a id="Router-new"></a>

### Router.new

```vex
export fn Router.new(): Router<{HTTP_FULL}>
```

Create an empty router.

**Returns:** `Router<{HTTP_FULL}>`

<a id="Router-new-2"></a>

### Router.new

```vex
export fn Router.new<const FEATURES: u32>(): Router<{FEATURES}>
```

**Type Parameters:**

- `const FEATURES: u32`

**Returns:** `Router<{FEATURES}>`

<a id="Router-selectWsProtocol"></a>

### Router.selectWsProtocol

```vex
export fn (self: &Router<FEATURES>) selectWsProtocol(routeId: i32, request: &Request): WsProtocolSelection
```

Select at most one client-offered protocol using immutable server

preference order. The compact pool keeps ordinary HTTP and WebSocket route
matching allocation-free after startup.

**Returns:** `WsProtocolSelection`

<a id="Router-addAsync"></a>

### Router.addAsync

```vex
export fn (self: &Router<FEATURES>!) addAsync(method: str, pattern: string, handlers: Vec<AsyncHandler>)
```

Register an explicit awaitable route. `handlers` is moved into immutable

router metadata at startup; the serving path copies only function values
into the task-owned `AsyncPipelineNext` chain.

<a id="Router-addBodyAsync"></a>

### Router.addBodyAsync

```vex
export fn (self: &Router<FEATURES>!) addBodyAsync(method: str, pattern: string, handlers: Vec<AsyncBodyHandler>)
```

Register an explicit task-owned request-body stream. Route selection occurs

after the complete header block but before body accumulation, allowing the
descriptor, admission lease and framing state to move as one unit.

<a id="Router-asyncHandlersFor"></a>

### Router.asyncHandlersFor

```vex
export fn (self: &Router<FEATURES>) asyncHandlersFor(routeId: i32): Vec<AsyncHandler>
```

Copy a selected route's function values into fresh task-owned storage.

Returning an empty vector is distinct from a valid route and keeps the
synchronous hot path branchless apart from its one route-id lookup.

**Returns:** `Vec<AsyncHandler>`

<a id="Router-hasAsyncRoute"></a>

### Router.hasAsyncRoute

```vex
export fn (self: &Router<FEATURES>) hasAsyncRoute(routeId: i32): bool
```

Test async-route membership without allocating task handler storage.

This is used on every routed request, so the synchronous hot path must
not build and immediately discard a handler vector just to make a branch.

**Returns:** `bool`

<a id="Router-hasAnyAsyncRoutes"></a>

### Router.hasAnyAsyncRoutes

```vex
export fn (self: &Router<FEATURES>) hasAnyAsyncRoutes(): bool
```

Zero-cost startup guard for workers which do not serve complete-body async

routes. H2 completion channels and wake descriptors are created only when
the frozen application can actually launch one of these tasks.

**Returns:** `bool`

<a id="Router-hasAnyResponseStreamRoutes"></a>

### Router.hasAnyResponseStreamRoutes

```vex
export fn (self: &Router<FEATURES>) hasAnyResponseStreamRoutes(): bool
```

Startup-only capability guard for protocol stream completion lanes.

**Returns:** `bool`

<a id="Router-asyncBodyHandlersFor"></a>

### Router.asyncBodyHandlersFor

```vex
export fn (self: &Router<FEATURES>) asyncBodyHandlersFor(routeId: i32): Vec<AsyncBodyHandler>
```

**Returns:** `Vec<AsyncBodyHandler>`

<a id="Router-hasAsyncBodyRoute"></a>

### Router.hasAsyncBodyRoute

```vex
export fn (self: &Router<FEATURES>) hasAsyncBodyRoute(routeId: i32): bool
```

**Returns:** `bool`

<a id="Router-hasAnyAsyncBodyRoutes"></a>

### Router.hasAnyAsyncBodyRoutes

```vex
export fn (self: &Router<FEATURES>) hasAnyAsyncBodyRoutes(): bool
```

Zero-cost global guard for applications which never register request-body

streams. Ordinary Fiber deployments avoid an early route lookup entirely.

**Returns:** `bool`

<a id="Router-add"></a>

### Router.add

```vex
export fn (self: &Router<FEATURES>!) add(method: str, pattern: str, handler: Handler)
```

Register a route with a method, pattern, and handler.

<a id="Router-addWs"></a>

### Router.addWs

```vex
export fn (self: &Router<FEATURES>!) addWs(pattern: str, handler: WsHandler)
```

Register a GET endpoint whose HTTP request is later promoted to a

worker-owned WebSocket session. The radix tree stores the ordinary marker
handler, while the endpoint callback remains route metadata until handoff.

<a id="Router-addWsWithLifecycle"></a>

### Router.addWsWithLifecycle

```vex
export fn (self: &Router<FEATURES>!) addWsWithLifecycle(pattern: str, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

Register a WebSocket endpoint with worker-owned lifecycle hooks. The hooks

are route metadata, not ordinary HTTP handlers: middleware still decides
whether an upgrade is allowed before `onOpen` can observe the session.

<a id="Router-addWsWithOptions"></a>

### Router.addWsWithOptions

```vex
export fn (self: &Router<FEATURES>!) addWsWithOptions(pattern: str, options: WsRouteOptions, handler: WsHandler)
```

Register a WebSocket endpoint with immutable subprotocol policy. Existing

`addWs` routes remain protocol-agnostic and pay no per-request allocation.

<a id="Router-addWsWithLifecycleOptions"></a>

### Router.addWsWithLifecycleOptions

```vex
export fn (self: &Router<FEATURES>!) addWsWithLifecycleOptions(pattern: str, options: WsRouteOptions, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

<a id="Router-addWsWithMiddleware"></a>

### Router.addWsWithMiddleware

```vex
export fn (self: &Router<FEATURES>!) addWsWithMiddleware(pattern: str, middlewares: Vec<Handler>, handler: WsHandler)
```

WebSocket equivalent of `addWithMiddleware`. The same terminal marker is

used, so authorization middleware runs before the HTTP→stream transfer and
may reject without ever handing the descriptor to a WebSocket callback.

<a id="Router-addWsWithMiddlewareLifecycle"></a>

### Router.addWsWithMiddlewareLifecycle

```vex
export fn (self: &Router<FEATURES>!) addWsWithMiddlewareLifecycle(pattern: str, middlewares: Vec<Handler>, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

Lifecycle variant of `addWsWithMiddleware`; route middleware remains

outside the session and can reject without producing an open callback.

<a id="Router-addWsWithMiddlewareOptions"></a>

### Router.addWsWithMiddlewareOptions

```vex
export fn (self: &Router<FEATURES>!) addWsWithMiddlewareOptions(pattern: str, middlewares: Vec<Handler>, options: WsRouteOptions, handler: WsHandler)
```

<a id="Router-addWsWithMiddlewareLifecycleOptions"></a>

### Router.addWsWithMiddlewareLifecycleOptions

```vex
export fn (self: &Router<FEATURES>!) addWsWithMiddlewareLifecycleOptions(pattern: str, middlewares: Vec<Handler>, options: WsRouteOptions, onOpen: Option<WsOpenHandler>, handler: WsHandler, onClose: Option<WsCloseHandler>)
```

<a id="Router-addStream"></a>

### Router.addStream

```vex
export fn (self: &Router<FEATURES>!) addStream(method: str, pattern: str, handler: StreamHandler)
```

Register a dynamic producer endpoint. It uses the same route metadata and

freeze-time radix tree as ordinary handlers; the terminal marker resolves
the producer from `routeStreamHandlers` after routing has completed.

<a id="Router-addStreamWithMiddleware"></a>

### Router.addStreamWithMiddleware

```vex
export fn (self: &Router<FEATURES>!) addStreamWithMiddleware(method: str, pattern: str, middlewares: Vec<Handler>, handler: StreamHandler)
```

Stream equivalent of `addWithMiddleware`. The producer still occupies only

the terminal chain slot; middleware remains ordinary `Handler` code and
retains before/after `next()` behavior.

<a id="Router-addStaticRoute"></a>

### Router.addStaticRoute

```vex
export fn (self: &Router<FEATURES>!) addStaticRoute(method: str, pattern: str, handler: Handler, root: string)
```

Register a static route with a method, pattern, handler, and root directory.

<a id="Router-addStaticRouteWithMiddleware"></a>

### Router.addStaticRouteWithMiddleware

```vex
export fn (self: &Router<FEATURES>!) addStaticRouteWithMiddleware(method: str, pattern: str, handler: Handler, root: string, middlewares: Vec<Handler>)
```

Register a static route with route-level middleware. This mirrors

addStaticRoute while preserving the same flat startup-only middleware pool
used by ordinary routes.

<a id="Router-addWithMiddleware"></a>

### Router.addWithMiddleware

```vex
export fn (self: &Router<FEATURES>!) addWithMiddleware(method: str, pattern: str, middlewares: Vec<Handler>, handler: Handler)
```

Register a route with route-level middleware.

Middleware runs in order before the handler (after global middleware).
Example: router.addWithMiddleware("GET", "/admin", authMW, handler)

<a id="Router-freeze"></a>

### Router.freeze

```vex
export fn (self: &Router<FEATURES>!) freeze()
```

Compile all routes into per-method radix trees.

Called once at startup. After this, find() uses O(L) tree lookup.

**Receiver:** `self: &Router<FEATURES>!` *(mutable reference)*

<a id="Router-find"></a>

### Router.find

```vex
export fn (self: &Router<FEATURES>!) find(method: str, path: str, ctx: &Ctx!): Option<Handler>
```

Find a matching route and extract parameters into ctx.

Frozen routers use O(L) radix lookup; mutable routers use the linear builder path.

**Returns:** `Option<Handler>`

<a id="Router-findFrozen"></a>

### Router.findFrozen

```vex
export fn (self: &Router<FEATURES>) findFrozen(method: str, path: str, ctx: &Ctx!): Option<Handler>
```

Match against a frozen router without mutating shared application state.

Server workers must use this entry point: the compiled radix trees are
immutable after `freeze()` and are therefore safe to share across tasks.

**Returns:** `Option<Handler>`

<a id="RequestHeaders-new"></a>

### RequestHeaders.new

```vex
export fn RequestHeaders.new(): RequestHeaders
```

**Returns:** `RequestHeaders`

<a id="RequestHeaders-get"></a>

### RequestHeaders.get

```vex
export fn (self: &RequestHeaders) get(name: str): str
```

Get header value by name (case-insensitive). Returns empty str if not found.

**Returns:** `str`

<a id="RequestHeaders-has"></a>

### RequestHeaders.has

```vex
export fn (self: &RequestHeaders) has(name: str): bool
```

Check if a header exists (case-insensitive).

**Returns:** `bool`

<a id="RequestHeaders-add"></a>

### RequestHeaders.add

```vex
export fn (self: &RequestHeaders!) add(name: str, value: str)
```

Add a header — zero-copy, stores str views directly.

<a id="RequestHeaders-clear"></a>

### RequestHeaders.clear

```vex
export fn (self: &RequestHeaders!) clear()
```

Clear all headers (no allocations — str is Copy).

**Receiver:** `self: &RequestHeaders!` *(mutable reference)*

<a id="RequestHeaders-len"></a>

### RequestHeaders.len

```vex
export fn (self: &RequestHeaders) len(): usize
```

Number of headers.

**Returns:** `usize`

<a id="Headers-new"></a>

### Headers.new

```vex
export fn Headers.new(): Headers
```

Create an empty Headers collection.

**Returns:** `Headers`

<a id="Headers-get"></a>

### Headers.get

```vex
export fn (self: &Headers) get(name: str): string
```

Get header value by name (case-insensitive).

Returns empty string if not found.
Uses .asStr() for zero-copy comparison — avoids heap alloc per iteration.

**Returns:** `string`

<a id="Headers-has"></a>

### Headers.has

```vex
export fn (self: &Headers) has(name: str): bool
```

Check if a header exists (case-insensitive).

Uses .asStr() for zero-copy comparison.

**Returns:** `bool`

<a id="Headers-set"></a>

### Headers.set

```vex
export fn (self: &Headers!) set(name: str, value: str)
```

Set a header. Replaces existing (case-insensitive) or appends.

<a id="Headers-add"></a>

### Headers.add

```vex
export fn (self: &Headers!) add(name: str, value: str)
```

Add a header (allows duplicate names, e.g. Set-Cookie).

<a id="Headers-del"></a>

### Headers.del

```vex
export fn (self: &Headers!) del(name: str)
```

Remove all headers with the given name (case-insensitive).

In-place removal — no allocation.

<a id="Headers-clear"></a>

### Headers.clear

```vex
export fn (self: &Headers!) clear()
```

Clear all headers.

**Receiver:** `self: &Headers!` *(mutable reference)*

<a id="Headers-shrinkToFit"></a>

### Headers.shrinkToFit

```vex
export fn (self: &Headers!) shrinkToFit()
```

Shrink underlying storage to match actual header count.

**Receiver:** `self: &Headers!` *(mutable reference)*

<a id="Headers-len"></a>

### Headers.len

```vex
export fn (self: &Headers) len(): usize
```

Number of headers.

**Returns:** `usize`

<a id="CorsConfig-new"></a>

### CorsConfig.new

```vex
export fn CorsConfig.new(origin: string): CorsConfig
```

Create a CORS config with a specific origin.

**Returns:** `CorsConfig`

<a id="CorsConfig-setMethods"></a>

### CorsConfig.setMethods

```vex
export fn (self: &CorsConfig!) setMethods(m: string): &CorsConfig!
```

Set allowed methods (chainable).

**Returns:** `&CorsConfig!`

<a id="CorsConfig-setHeaders"></a>

### CorsConfig.setHeaders

```vex
export fn (self: &CorsConfig!) setHeaders(h: string): &CorsConfig!
```

Set allowed headers (chainable).

**Returns:** `&CorsConfig!`

<a id="CorsConfig-setMaxAge"></a>

### CorsConfig.setMaxAge

```vex
export fn (self: &CorsConfig!) setMaxAge(age: string): &CorsConfig!
```

Set max age for preflight cache (chainable).

**Returns:** `&CorsConfig!`

<a id="CorsConfig-allowCredentials"></a>

### CorsConfig.allowCredentials

```vex
export fn (self: &CorsConfig!) allowCredentials(): &CorsConfig!
```

Enable credentials (chainable).

**Returns:** `&CorsConfig!`

<a id="CorsConfig-build"></a>

### CorsConfig.build

```vex
export fn (self: &CorsConfig) build(): Handler
```

Build a Handler from this config.

**Returns:** `Handler`

<a id="BodyPageRing-new"></a>

### BodyPageRing.new

```vex
export fn BodyPageRing.new(pageCount: usize, pageBytes: usize): Option<BodyPageRing>
```

Create a bounded owned page ring. Zero dimensions and overflowing total

capacity are rejected before allocation; callers choose the explicit page
budget as part of route admission rather than accepting an implicit
unbounded upload buffer.

**Returns:** `Option<BodyPageRing>`

<a id="BodyPageRing-capacity"></a>

### BodyPageRing.capacity

```vex
export fn (self: &BodyPageRing) capacity(): usize
```

Total fixed storage reserved by this ring.

**Returns:** `usize`

<a id="BodyPageRing-len"></a>

### BodyPageRing.len

```vex
export fn (self: &BodyPageRing) len(): usize
```

Number of decoded bytes currently owned by the ring.

**Returns:** `usize`

<a id="BodyPageRing-isEmpty"></a>

### BodyPageRing.isEmpty

```vex
export fn (self: &BodyPageRing) isEmpty(): bool
```

**Returns:** `bool`

<a id="BodyPageRing-free"></a>

### BodyPageRing.free

```vex
export fn (self: &BodyPageRing) free(): usize
```

Remaining bounded storage. A zero result is the backpressure signal: the

producer must not read another socket fragment until the route task drains
at least one current readable segment.

**Returns:** `usize`

<a id="BodyPageRing-writable"></a>

### BodyPageRing.writable

```vex
export fn (self: &BodyPageRing) writable(): usize
```

Bytes that may be committed through `writePtr` without crossing one page.

The value is always bounded by `free()` and is zero when the ring is full.

**Returns:** `usize`

<a id="BodyPageRing-writePtr"></a>

### BodyPageRing.writePtr

```vex
export fn (self: &BodyPageRing!) writePtr(): Ptr<u8!>
```

Writable tail storage for one bounded producer operation. It is valid only

up to `writable()` bytes, and the producer must call `commitWrite` exactly
once after populating it. A full ring returns a null pointer instead of
exposing a stale page.

**Returns:** `Ptr<u8!>`

<a id="BodyPageRing-commitWrite"></a>

### BodyPageRing.commitWrite

```vex
export fn (self: &BodyPageRing!) commitWrite(count: usize): bool
```

Commit bytes written through the current writable page. Invalid counts do

not alter any cursor, so a faulty transport adapter cannot corrupt queued
body ownership.

**Returns:** `bool`

<a id="BodyPageRing-write"></a>

### BodyPageRing.write

```vex
export fn (self: &BodyPageRing!) write(data: str): bool
```

Copy a complete caller-owned fragment into the bounded pages. This is the

convenience path for parser adapters; unlike a partial append it either
accepts the full fragment or leaves the ring untouched, preserving an
exact backpressure boundary.

**Returns:** `bool`

<a id="BodyPageRing-readable"></a>

### BodyPageRing.readable

```vex
export fn (self: &BodyPageRing) readable(): usize
```

Bytes available to one consumer callback without crossing a page. The

resulting view is borrowed from the ring and becomes invalid after its
corresponding `consume` or any subsequent mutable ring operation.

**Returns:** `usize`

<a id="BodyPageRing-readChunk"></a>

### BodyPageRing.readChunk

```vex
export fn (self: &BodyPageRing) readChunk(): str
```

Borrow the current readable page fragment. Empty rings return an empty

view; they never manufacture a pointer into uninitialized storage.

**Returns:** `str`

<a id="BodyPageRing-consume"></a>

### BodyPageRing.consume

```vex
export fn (self: &BodyPageRing!) consume(count: usize): bool
```

Release exactly a prefix of the current readable page. Crossing a page in

one call is intentionally rejected: that keeps every route callback's
borrowed view and the following cursor transition unambiguous.

**Returns:** `bool`

<a id="BodyPageRing-reset"></a>

### BodyPageRing.reset

```vex
export fn (self: &BodyPageRing!) reset()
```

Clear queued ownership after a terminal request transition. Pages remain

allocated for the next route/task, while every borrowed payload view has
to be discarded by the caller before reset.

**Receiver:** `self: &BodyPageRing!` *(mutable reference)*

<a id="BodyReader-new"></a>

### BodyReader.new

```vex
export fn BodyReader.new(mode: BodyMode): BodyReader
```

**Returns:** `BodyReader`

<a id="RequestBodyLifecycle-new"></a>

### RequestBodyLifecycle.new

```vex
export fn RequestBodyLifecycle.new(mode: BodyMode): RequestBodyLifecycle
```

**Returns:** `RequestBodyLifecycle`

<a id="DecodedBodyLifecycle-new"></a>

### DecodedBodyLifecycle.new

```vex
export fn DecodedBodyLifecycle.new(mode: BodyMode, declaredLength: i64, maxBodyBytes: usize): DecodedBodyLifecycle
```

**Returns:** `DecodedBodyLifecycle`

<a id="DecodedBodyLifecycle-begin"></a>

### DecodedBodyLifecycle.begin

```vex
export fn (self: &DecodedBodyLifecycle!) begin<C>(consumer: &C!): bool where C: RequestBodyConsumer
```

Admit exactly one consumer. Invalid or oversized declared lengths are

rejected before application code observes a partial lifecycle.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `boolwhere C: RequestBodyConsumer`

<a id="DecodedBodyLifecycle-accept"></a>

### DecodedBodyLifecycle.accept

```vex
export fn (self: &DecodedBodyLifecycle!) accept<C>( bytes: str, consumer: &C!, ): BodyResult where C: RequestBodyConsumer
```

Deliver one already-decoded protocol payload synchronously. Accounting is

committed only after the consumer accepts the borrowed view.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `BodyResultwhere C: RequestBodyConsumer`

<a id="DecodedBodyLifecycle-finish"></a>

### DecodedBodyLifecycle.finish

```vex
export fn (self: &DecodedBodyLifecycle!) finish<C>( consumer: &C!, ): BodyResult where C: RequestBodyConsumer
```

Complete the protocol-neutral stream boundary exactly once. A declared

content length is an equality constraint at END_STREAM, not only a cap.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `BodyResultwhere C: RequestBodyConsumer`

<a id="DecodedBodyLifecycle-cancel"></a>

### DecodedBodyLifecycle.cancel

```vex
export fn (self: &DecodedBodyLifecycle!) cancel<C>(consumer: &C!) where C: RequestBodyConsumer
```

Idempotently cancel an admitted consumer without publishing completion.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

<a id="DecodedBodyLifecycle-rearm"></a>

### DecodedBodyLifecycle.rearm

```vex
export fn (self: &DecodedBodyLifecycle!) rearm(mode: BodyMode, declaredLength: i64, maxBodyBytes: usize): bool
```

Re-arm only after a terminal transition; active borrowed callbacks can

therefore never race with storage reuse.

**Returns:** `bool`

<a id="RequestBodyLifecycle-begin"></a>

### RequestBodyLifecycle.begin

```vex
export fn (self: &RequestBodyLifecycle!) begin<C>( consumer: &C!, maxBodyBytes: usize, ): bool where C: RequestBodyConsumer
```

Begin one consumer exactly once. A consumer that rejects admission is

cancelled immediately and this lifecycle cannot be reused without `reset`.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `boolwhere C: RequestBodyConsumer`

<a id="RequestBodyLifecycle-feed"></a>

### RequestBodyLifecycle.feed

```vex
export fn (self: &RequestBodyLifecycle!) feed<C>( data: str, consumer: &C!, maxBodyBytes: usize, ): BodyResult where C: RequestBodyConsumer
```

Decode one transport fragment into an admitted consumer. Calls after a

terminal transition fail closed; successful completion invokes `finish`
once and only once.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `BodyResultwhere C: RequestBodyConsumer`

<a id="RequestBodyLifecycle-connectionClosed"></a>

### RequestBodyLifecycle.connectionClosed

```vex
export fn (self: &RequestBodyLifecycle!) connectionClosed<C>( consumer: &C!, ): bool where C: RequestBodyConsumer
```

Terminal peer-close handling. Only close-delimited bodies may finish at EOF;

every framed body is cancelled because its declared boundary was not reached.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

**Returns:** `boolwhere C: RequestBodyConsumer`

<a id="RequestBodyLifecycle-cancel"></a>

### RequestBodyLifecycle.cancel

```vex
export fn (self: &RequestBodyLifecycle!) cancel<C>(consumer: &C!) where C: RequestBodyConsumer
```

Cancel an admitted consumer due to deadline, routing failure, or explicit

shutdown. It is idempotent and never calls `finish`.

**Type Parameters:**

- `C`

**Where:**

- `RequestBodyConsumer`: `RequestBodyConsumer`

<a id="RequestBodyLifecycle-reset"></a>

### RequestBodyLifecycle.reset

```vex
export fn (self: &RequestBodyLifecycle!) reset(mode: BodyMode): bool
```

Reset only after a terminal transition. This makes accidental reuse while

a borrowed chunk callback is active impossible by construction.

**Returns:** `bool`

<a id="BodyReader-feedInto"></a>

### BodyReader.feedInto

```vex
export fn (self: &BodyReader!) feedInto(data: str, output: &StringBuilder!, maxBodyBytes: usize): BodyResult
```

Consume one transport fragment and append decoded bytes to `output`.

`progress.consumed` always refers to this call's `data` view, so a caller
can retain the exact suffix for pipelined messages without guessing.

**Returns:** `BodyResult`

<a id="BodyReader-feedTo"></a>

### BodyReader.feedTo

```vex
export fn (self: &BodyReader!) feedTo<S>( data: str, sink: &S!, maxBodyBytes: usize, ): BodyResult where S: ChunkSink
```

Consume one transport fragment through a caller-owned decoded-byte sink.

This is the zero-copy parser seam used by the HTTP/1 request lifecycle:
data reaches `sink` as borrowed `str` views into the current transport
fragment, with no response-sized intermediate allocation. The sink must
consume each view synchronously and must return `false` to fail closed.
`progress.consumed` remains relative to this call's `data` view.

**Type Parameters:**

- `S`

**Where:**

- `ChunkSink`: `ChunkSink`

**Returns:** `BodyResultwhere S: ChunkSink`

<a id="BodyReader-connectionClosed"></a>

### BodyReader.connectionClosed

```vex
export fn (self: &BodyReader!) connectionClosed()
```

**Receiver:** `self: &BodyReader!` *(mutable reference)*

<a id="BodyReader-isDone"></a>

### BodyReader.isDone

```vex
export fn (self: &BodyReader) isDone(): bool
```

**Returns:** `bool`

<a id="BodyReader-totalBytes"></a>

### BodyReader.totalBytes

```vex
export fn (self: &BodyReader) totalBytes(): usize
```

**Returns:** `usize`

<a id="BodyReader-reset"></a>

### BodyReader.reset

```vex
export fn (self: &BodyReader!) reset(mode: BodyMode)
```

<a id="ChunkedDecoder-new"></a>

### ChunkedDecoder.new

```vex
export fn ChunkedDecoder.new(): ChunkedDecoder
```

**Returns:** `ChunkedDecoder`

<a id="ChunkedDecoder-decodeTo"></a>

### ChunkedDecoder.decodeTo

```vex
export fn (self: &ChunkedDecoder!) decodeTo<S>( input: str, sink: &S!, maxBodyBytes: usize, ): ChunkResult where S: ChunkSink
```

Incrementally decode one input fragment into a caller-owned sink.

`maxBodyBytes` is checked before every append. On `NeedMore`, bytes before
`progress.consumed` are permanently consumed; the unconsumed suffix must be
prepended to the next fragment. On `Complete`, the suffix after `consumed`
is the next pipelined message and is never swallowed by this decoder.

**Type Parameters:**

- `S`

**Where:**

- `ChunkSink`: `ChunkSink`

**Returns:** `ChunkResultwhere S: ChunkSink`

<a id="ChunkedDecoder-decodeInto"></a>

### ChunkedDecoder.decodeInto

```vex
export fn (self: &ChunkedDecoder!) decodeInto(input: str, output: &StringBuilder!, maxBodyBytes: usize): ChunkResult
```

Buffered convenience form of `decodeTo`.

Kept for source compatibility and small callers; applications which
already own a stateful destination can call `decodeTo` and avoid the
response-sized accumulation entirely.

**Returns:** `ChunkResult`

<a id="ChunkedDecoder-reset"></a>

### ChunkedDecoder.reset

```vex
export fn (self: &ChunkedDecoder!) reset()
```

**Receiver:** `self: &ChunkedDecoder!` *(mutable reference)*

<a id="ChunkedDecoder-isDone"></a>

### ChunkedDecoder.isDone

```vex
export fn (self: &ChunkedDecoder) isDone(): bool
```

**Returns:** `bool`

<a id="ChunkedDecoder-isError"></a>

### ChunkedDecoder.isError

```vex
export fn (self: &ChunkedDecoder) isError(): bool
```

**Returns:** `bool`

<a id="FiberRequestLimits-defaults"></a>

### FiberRequestLimits.defaults

```vex
export fn FiberRequestLimits.defaults(): FiberRequestLimits
```

**Returns:** `FiberRequestLimits`

<a id="FiberParsedRequest-empty"></a>

### FiberParsedRequest.empty

```vex
export fn FiberParsedRequest.empty(): FiberParsedRequest
```

**Returns:** `FiberParsedRequest`

<a id="FiberParsedRequest-clearBorrowedViews"></a>

### FiberParsedRequest.clearBorrowedViews

```vex
export fn (self: &FiberParsedRequest!) clearBorrowedViews()
```

End every view currently published by this reusable parse scratch.

**Receiver:** `self: &FiberParsedRequest!` *(mutable reference)*

<a id="H2Frame-isEndStream"></a>

### H2Frame.isEndStream

```vex
export fn (self: &H2Frame) isEndStream(): bool
```

Has END_STREAM flag?

**Returns:** `bool`

<a id="H2Frame-isEndHeaders"></a>

### H2Frame.isEndHeaders

```vex
export fn (self: &H2Frame) isEndHeaders(): bool
```

Has END_HEADERS flag?

**Returns:** `bool`

<a id="H2Frame-isPadded"></a>

### H2Frame.isPadded

```vex
export fn (self: &H2Frame) isPadded(): bool
```

Has PADDED flag?

**Returns:** `bool`

<a id="H2Frame-hasPriority"></a>

### H2Frame.hasPriority

```vex
export fn (self: &H2Frame) hasPriority(): bool
```

Has PRIORITY flag?

**Returns:** `bool`

<a id="H2Frame-isAck"></a>

### H2Frame.isAck

```vex
export fn (self: &H2Frame) isAck(): bool
```

Has ACK flag?

**Returns:** `bool`

<a id="H2Settings-defaults"></a>

### H2Settings.defaults

```vex
export fn H2Settings.defaults(): H2Settings
```

Default HTTP/2 settings.

**Returns:** `H2Settings`

<a id="H2ConnectionState-new"></a>

### H2ConnectionState.new

```vex
export fn H2ConnectionState.new(role: H2EndpointRole): H2ConnectionState
```

Create connection state with explicit endpoint ownership. Clients initiate

odd streams; servers initiate even streams (including pushed streams).

**Returns:** `H2ConnectionState`

<a id="H2ConnectionState-openLocalStream"></a>

### H2ConnectionState.openLocalStream

```vex
export fn (self: &H2ConnectionState!) openLocalStream(streams: &StreamMap!): H2StreamAdmissionResult
```

Open the next locally owned stream and materialize it atomically. Once a

peer GOAWAY is received, no new local stream is admitted; callers may retry
work whose prior stream ID is above the peer's last-stream boundary.

**Returns:** `H2StreamAdmissionResult`

<a id="H2ConnectionState-acceptRemoteStream"></a>

### H2ConnectionState.acceptRemoteStream

```vex
export fn (self: &H2ConnectionState!) acceptRemoteStream(streams: &StreamMap!, id: u32): H2StreamAdmissionResult
```

Admit a peer-owned stream under parity, monotonic-ID, GOAWAY and concurrent

stream rules. Valid refused/ignored IDs are consumed so they cannot later be
reused as if they were new.

**Returns:** `H2StreamAdmissionResult`

<a id="H2ConnectionState-localStreamMayHaveBeenProcessed"></a>

### H2ConnectionState.localStreamMayHaveBeenProcessed

```vex
export fn (self: &H2ConnectionState) localStreamMayHaveBeenProcessed(id: u32): bool
```

Whether the peer's GOAWAY confirms that a locally initiated stream may have

been processed. False means the operation is safe to consider for retry.

**Returns:** `bool`

<a id="H2ConnectionState-applyReceivedPriorityUpdate"></a>

### H2ConnectionState.applyReceivedPriorityUpdate

```vex
export fn (self: &H2ConnectionState!) applyReceivedPriorityUpdate(update: &H2PriorityUpdate, streams: &StreamMap, scheduler: &H2PriorityScheduler!): H2ConnectionResult
```

Apply a client PRIORITY_UPDATE to the bounded scheduler. Request priorities

may arrive before their stream opens. Push priorities must reference an
already reserved/open local push stream; closed targets are discarded.

**Returns:** `H2ConnectionResult`

<a id="H2ConnectionState-reserveSendData"></a>

### H2ConnectionState.reserveSendData

```vex
export fn (self: &H2ConnectionState!) reserveSendData(stream: &H2Stream!, flowBytes: u32): H2FlowResult
```

Atomically reserve connection and stream credit for outgoing DATA.

`flowBytes` is the complete DATA payload length, including padding fields.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-acceptReceivedData"></a>

### H2ConnectionState.acceptReceivedData

```vex
export fn (self: &H2ConnectionState!) acceptReceivedData(stream: &H2Stream!, flowBytes: u32): H2FlowResult
```

Atomically account peer DATA against connection and stream receive credit.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-acceptReceivedDiscardedData"></a>

### H2ConnectionState.acceptReceivedDiscardedData

```vex
export fn (self: &H2ConnectionState!) acceptReceivedDiscardedData(flowBytes: u32): H2FlowResult
```

Account DATA that arrived after the peer-facing side of a stream closed.

RFC 9113 section 5.1 requires discarding those stream bytes while still
charging the connection receive window, unless the connection itself fails.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-recvConnectionWindowUpdate"></a>

### H2ConnectionState.recvConnectionWindowUpdate

```vex
export fn (self: &H2ConnectionState!) recvConnectionWindowUpdate(increment: u32): H2FlowResult
```

Apply a peer connection-level WINDOW_UPDATE to local send credit.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-sendConnectionWindowUpdate"></a>

### H2ConnectionState.sendConnectionWindowUpdate

```vex
export fn (self: &H2ConnectionState!) sendConnectionWindowUpdate(increment: u32): H2FlowResult
```

Record a locally emitted connection WINDOW_UPDATE in receive credit.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-recvStreamWindowUpdate"></a>

### H2ConnectionState.recvStreamWindowUpdate

```vex
export fn (self: &H2ConnectionState!) recvStreamWindowUpdate(stream: &H2Stream!, increment: u32): H2FlowResult
```

Apply a peer stream-level WINDOW_UPDATE to local send credit.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-sendStreamWindowUpdate"></a>

### H2ConnectionState.sendStreamWindowUpdate

```vex
export fn (self: &H2ConnectionState!) sendStreamWindowUpdate(stream: &H2Stream!, increment: u32): H2FlowResult
```

Record a locally emitted stream WINDOW_UPDATE in receive credit.

**Returns:** `H2FlowResult`

<a id="H2ConnectionState-recvFrame"></a>

### H2ConnectionState.recvFrame

```vex
export fn (self: &H2ConnectionState!) recvFrame(frame: &H2Frame): H2ConnectionResult
```

Apply a peer frame to connection-owned receive sequencing.

**Returns:** `H2ConnectionResult`

<a id="H2ConnectionState-sendFrame"></a>

### H2ConnectionState.sendFrame

```vex
export fn (self: &H2ConnectionState!) sendFrame(frame: &H2Frame): H2ConnectionResult
```

Apply a local frame to connection-owned send sequencing.

**Returns:** `H2ConnectionResult`

<a id="H2ConnectionState-recordReceivedGoAway"></a>

### H2ConnectionState.recordReceivedGoAway

```vex
export fn (self: &H2ConnectionState!) recordReceivedGoAway(goAway: &GoAway): H2ConnectionResult
```

Record an accepted peer GOAWAY payload. Later GOAWAY frames may reduce, but

never increase, the last processed stream identifier.

**Returns:** `H2ConnectionResult`

<a id="H2ConnectionState-recordSentGoAway"></a>

### H2ConnectionState.recordSentGoAway

```vex
export fn (self: &H2ConnectionState!) recordSentGoAway(goAway: &GoAway): H2ConnectionResult
```

Record a locally emitted GOAWAY payload under the same non-increasing rule.

**Returns:** `H2ConnectionResult`

<a id="H2Priority-defaults"></a>

### H2Priority.defaults

```vex
export fn H2Priority.defaults(): H2Priority
```

**Returns:** `H2Priority`

<a id="H2Priority-new"></a>

### H2Priority.new

```vex
export fn H2Priority.new(urgency: u8, incremental: bool): Option<H2Priority>
```

**Returns:** `Option<H2Priority>`

<a id="H2PriorityScheduler-new"></a>

### H2PriorityScheduler.new

```vex
export fn H2PriorityScheduler.new(capacity: u32, maximumChunkBytes: u32, starvationTurns: u64): Option<H2PriorityScheduler>
```

Create a bounded scheduler. `starvationTurns` is the maximum normal-priority

selections before an older ready entry becomes eligible for forced service.

**Returns:** `Option<H2PriorityScheduler>`

<a id="H2PriorityScheduler-defaults"></a>

### H2PriorityScheduler.defaults

```vex
export fn H2PriorityScheduler.defaults(capacity: u32): Option<H2PriorityScheduler>
```

**Returns:** `Option<H2PriorityScheduler>`

<a id="H2PriorityScheduler-len"></a>

### H2PriorityScheduler.len

```vex
export fn (self: &H2PriorityScheduler) len(): usize
```

**Returns:** `usize`

<a id="H2PriorityScheduler-isRegistered"></a>

### H2PriorityScheduler.isRegistered

```vex
export fn (self: &H2PriorityScheduler) isRegistered(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-isFull"></a>

### H2PriorityScheduler.isFull

```vex
export fn (self: &H2PriorityScheduler) isFull(): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-remainingCapacity"></a>

### H2PriorityScheduler.remainingCapacity

```vex
export fn (self: &H2PriorityScheduler) remainingCapacity(): u32
```

**Returns:** `u32`

<a id="H2PriorityScheduler-hasPendingWork"></a>

### H2PriorityScheduler.hasPendingWork

```vex
export fn (self: &H2PriorityScheduler) hasPendingWork(): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-hasFlowBlockedWork"></a>

### H2PriorityScheduler.hasFlowBlockedWork

```vex
export fn (self: &H2PriorityScheduler) hasFlowBlockedWork(): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-priorityFor"></a>

### H2PriorityScheduler.priorityFor

```vex
export fn (self: &H2PriorityScheduler) priorityFor(streamId: u32): Option<H2Priority>
```

**Returns:** `Option<H2Priority>`

<a id="H2PriorityScheduler-streamIdAt"></a>

### H2PriorityScheduler.streamIdAt

```vex
export fn (self: &H2PriorityScheduler) streamIdAt(index: usize): Option<u32>
```

Inspect bounded registry identity without exposing mutable entries. Protocol

owners use this to retire priorities for stream IDs implicitly closed by a
newer peer stream.

**Returns:** `Option<u32>`

<a id="H2PriorityScheduler-register"></a>

### H2PriorityScheduler.register

```vex
export fn (self: &H2PriorityScheduler!) register(streamId: u32, priority: H2Priority): H2PriorityRegistrationResult
```

Register an active or idle stream. Re-registration is a reprioritization and

never grows the bounded registry.

**Returns:** `H2PriorityRegistrationResult`

<a id="H2PriorityScheduler-markReady"></a>

### H2PriorityScheduler.markReady

```vex
export fn (self: &H2PriorityScheduler!) markReady(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-markBlocked"></a>

### H2PriorityScheduler.markBlocked

```vex
export fn (self: &H2PriorityScheduler!) markBlocked(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-markFlowBlocked"></a>

### H2PriorityScheduler.markFlowBlocked

```vex
export fn (self: &H2PriorityScheduler!) markFlowBlocked(streamId: u32): bool
```

Park application-ready work behind stream flow control without forgetting

that bytes remain pending.

**Returns:** `bool`

<a id="H2PriorityScheduler-markFlowWritable"></a>

### H2PriorityScheduler.markFlowWritable

```vex
export fn (self: &H2PriorityScheduler!) markFlowWritable(streamId: u32): bool
```

Publish new stream credit. Pending work becomes selectable again without a

second application wakeup.

**Returns:** `bool`

<a id="H2PriorityScheduler-remove"></a>

### H2PriorityScheduler.remove

```vex
export fn (self: &H2PriorityScheduler!) remove(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2PriorityScheduler-cancel"></a>

### H2PriorityScheduler.cancel

```vex
export fn (self: &H2PriorityScheduler!) cancel(streamId: u32): bool
```

Cancel a registered stream even when another selection lease is active.

The selected index is repaired when removal shifts it; cancelling the
selected stream also revokes that lease. Capacity is retained for reuse.

**Returns:** `bool`

<a id="H2PriorityScheduler-clear"></a>

### H2PriorityScheduler.clear

```vex
export fn (self: &H2PriorityScheduler!) clear()
```

Drop all active and idle priority state while retaining pre-reserved

storage. Any outstanding selection lease is revoked.

**Receiver:** `self: &H2PriorityScheduler!` *(mutable reference)*

<a id="H2PriorityScheduler-next"></a>

### H2PriorityScheduler.next

```vex
export fn (self: &H2PriorityScheduler!) next(maximumBytes: u32): H2ScheduleResult
```

Reserve one bounded scheduling turn. Exactly one selection may be in flight;

`complete` publishes whether the stream remains ready.

**Returns:** `H2ScheduleResult`

<a id="H2PriorityScheduler-selectedStreamId"></a>

### H2PriorityScheduler.selectedStreamId

```vex
export fn (self: &H2PriorityScheduler) selectedStreamId(): Option<u32>
```

**Returns:** `Option<u32>`

<a id="H2PriorityScheduler-selectedRemainingBytes"></a>

### H2PriorityScheduler.selectedRemainingBytes

```vex
export fn (self: &H2PriorityScheduler) selectedRemainingBytes(): u32
```

**Returns:** `u32`

<a id="H2PriorityScheduler-capSelectedBudget"></a>

### H2PriorityScheduler.capSelectedBudget

```vex
export fn (self: &H2PriorityScheduler!) capSelectedBudget(streamId: u32, maximumBytes: u32): bool
```

Narrow a selected turn after connection/stream flow windows are applied.

**Returns:** `bool`

<a id="H2PriorityScheduler-consumeSelectedBudget"></a>

### H2PriorityScheduler.consumeSelectedBudget

```vex
export fn (self: &H2PriorityScheduler!) consumeSelectedBudget(streamId: u32, byteCount: u32): bool
```

Consume bytes from the current selection lease. This enforces the scheduler

chunk contract even when a transport performs more than one partial write.

**Returns:** `bool`

<a id="H2PriorityScheduler-restoreSelectedBudget"></a>

### H2PriorityScheduler.restoreSelectedBudget

```vex
export fn (self: &H2PriorityScheduler!) restoreSelectedBudget(streamId: u32, byteCount: u32): bool
```

Restore a provisional budget reservation when flow-control mutation fails.

**Returns:** `bool`

<a id="H2PriorityScheduler-complete"></a>

### H2PriorityScheduler.complete

```vex
export fn (self: &H2PriorityScheduler!) complete(streamId: u32, stillReady: bool): bool
```

Complete the outstanding selection. `stillReady=true` requeues it without

allocation; false leaves it registered but dormant for flow-control wakeup.

**Returns:** `bool`

<a id="H2PriorityScheduler-completeFlowBlocked"></a>

### H2PriorityScheduler.completeFlowBlocked

```vex
export fn (self: &H2PriorityScheduler!) completeFlowBlocked(streamId: u32): bool
```

Complete a selected turn that discovered exhausted stream credit. Pending

application work is retained and automatically wakes on markFlowWritable.

**Returns:** `bool`

<a id="H2ProtocolConfig-defaults"></a>

### H2ProtocolConfig.defaults

```vex
export fn H2ProtocolConfig.defaults(): H2ProtocolConfig
```

**Returns:** `H2ProtocolConfig`

<a id="H2ProtocolConfig-isValid"></a>

### H2ProtocolConfig.isValid

```vex
export fn (self: &H2ProtocolConfig) isValid(): bool
```

**Returns:** `bool`

<a id="H2HeaderFrameCursor-remainingPayloadBytes"></a>

### H2HeaderFrameCursor.remainingPayloadBytes

```vex
export fn (self: &H2HeaderFrameCursor) remainingPayloadBytes(): usize
```

**Returns:** `usize`

<a id="H2HeaderFrameCursor-remainingFragmentCount"></a>

### H2HeaderFrameCursor.remainingFragmentCount

```vex
export fn (self: &H2HeaderFrameCursor) remainingFragmentCount(): usize
```

**Returns:** `usize`

<a id="H2HeaderFrameCursor-remainingWireBytes"></a>

### H2HeaderFrameCursor.remainingWireBytes

```vex
export fn (self: &H2HeaderFrameCursor) remainingWireBytes(): usize
```

Remaining payload plus the nine-byte header for every remaining frame.

A transport can reserve this exact queue capacity before draining the
cursor, preventing partial enqueue/interleaving of a compressed block.

**Returns:** `usize`

<a id="H2HeaderFrameCursor-nextWireBytes"></a>

### H2HeaderFrameCursor.nextWireBytes

```vex
export fn (self: &H2HeaderFrameCursor) nextWireBytes(): usize
```

Exact destination capacity required by the next cursor turn without

advancing it. Egress can reserve/copy atomically and never consume a
fragment merely to discover that its socket queue is too small.

**Returns:** `usize`

<a id="H2HeaderFrameCursor-next"></a>

### H2HeaderFrameCursor.next

```vex
export fn (self: &H2HeaderFrameCursor!) next(): Option<H2HeaderFragment>
```

**Returns:** `Option<H2HeaderFragment>`

<a id="H2ProtocolState-new"></a>

### H2ProtocolState.new

```vex
export fn H2ProtocolState.new(role: H2EndpointRole, config: H2ProtocolConfig): Option<H2ProtocolState>
```

Create one bounded owner for connection sequencing, live stream slots and

active/idle priority state. The scheduler and stream map use the same
concurrent capacity by construction.

**Returns:** `Option<H2ProtocolState>`

<a id="H2ProtocolState-role"></a>

### H2ProtocolState.role

```vex
export fn (self: &H2ProtocolState) role(): H2EndpointRole
```

**Returns:** `H2EndpointRole`

<a id="H2ProtocolState-activeStreamCount"></a>

### H2ProtocolState.activeStreamCount

```vex
export fn (self: &H2ProtocolState) activeStreamCount(): u32
```

**Returns:** `u32`

<a id="H2ProtocolState-residentStreamCount"></a>

### H2ProtocolState.residentStreamCount

```vex
export fn (self: &H2ProtocolState) residentStreamCount(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-priorityStateCount"></a>

### H2ProtocolState.priorityStateCount

```vex
export fn (self: &H2ProtocolState) priorityStateCount(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-bufferedHeaderBytes"></a>

### H2ProtocolState.bufferedHeaderBytes

```vex
export fn (self: &H2ProtocolState) bufferedHeaderBytes(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-remainingIngressDiscardBytes"></a>

### H2ProtocolState.remainingIngressDiscardBytes

```vex
export fn (self: &H2ProtocolState) remainingIngressDiscardBytes(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-receiveDynamicTableBytes"></a>

### H2ProtocolState.receiveDynamicTableBytes

```vex
export fn (self: &H2ProtocolState) receiveDynamicTableBytes(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-sendDynamicTableBytes"></a>

### H2ProtocolState.sendDynamicTableBytes

```vex
export fn (self: &H2ProtocolState) sendDynamicTableBytes(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-sendMaximumDynamicTableBytes"></a>

### H2ProtocolState.sendMaximumDynamicTableBytes

```vex
export fn (self: &H2ProtocolState) sendMaximumDynamicTableBytes(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-hasPendingSendTableSizeUpdate"></a>

### H2ProtocolState.hasPendingSendTableSizeUpdate

```vex
export fn (self: &H2ProtocolState) hasPendingSendTableSizeUpdate(): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-effectiveLocalSettings"></a>

### H2ProtocolState.effectiveLocalSettings

```vex
export fn (self: &H2ProtocolState) effectiveLocalSettings(): H2Settings
```

**Returns:** `H2Settings`

<a id="H2ProtocolState-effectivePeerSettings"></a>

### H2ProtocolState.effectivePeerSettings

```vex
export fn (self: &H2ProtocolState) effectivePeerSettings(): H2Settings
```

**Returns:** `H2Settings`

<a id="H2ProtocolState-pendingLocalSettingsCount"></a>

### H2ProtocolState.pendingLocalSettingsCount

```vex
export fn (self: &H2ProtocolState) pendingLocalSettingsCount(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-pendingLocalPingCount"></a>

### H2ProtocolState.pendingLocalPingCount

```vex
export fn (self: &H2ProtocolState) pendingLocalPingCount(): usize
```

**Returns:** `usize`

<a id="H2ProtocolState-receiveMaximumFrameSize"></a>

### H2ProtocolState.receiveMaximumFrameSize

```vex
export fn (self: &H2ProtocolState) receiveMaximumFrameSize(): u32
```

**Returns:** `u32`

<a id="H2ProtocolState-sendMaximumFrameSize"></a>

### H2ProtocolState.sendMaximumFrameSize

```vex
export fn (self: &H2ProtocolState) sendMaximumFrameSize(): u32
```

**Returns:** `u32`

<a id="H2ProtocolState-isClosed"></a>

### H2ProtocolState.isClosed

```vex
export fn (self: &H2ProtocolState) isClosed(): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-lastRemoteStreamId"></a>

### H2ProtocolState.lastRemoteStreamId

```vex
export fn (self: &H2ProtocolState) lastRemoteStreamId(): u32
```

Highest peer-owned stream identifier admitted or refused by this

connection. Transport uses this structural boundary for GOAWAY; it never
reconstructs lifecycle state from response names or resident slots.

**Returns:** `u32`

<a id="H2ProtocolState-isDraining"></a>

### H2ProtocolState.isDraining

```vex
export fn (self: &H2ProtocolState) isDraining(): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-streamState"></a>

### H2ProtocolState.streamState

```vex
export fn (self: &H2ProtocolState) streamState(streamId: u32): Option<StreamState>
```

**Returns:** `Option<StreamState>`

<a id="H2ProtocolState-streamPriority"></a>

### H2ProtocolState.streamPriority

```vex
export fn (self: &H2ProtocolState) streamPriority(streamId: u32): Option<H2Priority>
```

**Returns:** `Option<H2Priority>`

<a id="H2ProtocolState-openLocalStream"></a>

### H2ProtocolState.openLocalStream

```vex
export fn (self: &H2ProtocolState!) openLocalStream(): H2StreamAdmissionResult
```

Open a locally owned stream only when its scheduler slot is also available.

No stream ID or map slot is consumed on capacity failure.

**Returns:** `H2StreamAdmissionResult`

<a id="H2ProtocolState-acceptRemoteStream"></a>

### H2ProtocolState.acceptRemoteStream

```vex
export fn (self: &H2ProtocolState!) acceptRemoteStream(streamId: u32): H2StreamAdmissionResult
```

Admit a peer stream and preserve any PRIORITY_UPDATE that raced ahead of

HEADERS. Active streams and prioritized idle streams consume the same
bounded registry. A capacity refusal consumes the valid peer ID but exposes
no partially active stream.

**Returns:** `H2StreamAdmissionResult`

<a id="H2ProtocolState-sendRstStreamFrame"></a>

### H2ProtocolState.sendRstStreamFrame

```vex
export fn (self: &H2ProtocolState!) sendRstStreamFrame(streamId: u32, errorCode: u32, out: &str!): H2SendResetResult
```

Cancel/reset a locally owned stream under one wire transaction. Active

streams are retired only after the complete RST_STREAM is encoded; an
undersized output therefore cannot lose a required reset. Idle stream IDs
and early priority records never existed on the wire and need no frame.

**Returns:** `H2SendResetResult`

<a id="H2ProtocolState-sendStreamErrorFrame"></a>

### H2ProtocolState.sendStreamErrorFrame

```vex
export fn (self: &H2ProtocolState!) sendStreamErrorFrame(streamId: u32, errorCode: u32, out: &str!): H2SendResetResult
```

Encode the RST_STREAM required by a locally detected receive-side stream

error. Receive validation deliberately retires the stream before exposing
its typed error, so this transaction cannot use the ordinary active-stream
cancellation path. `resetSent` keeps the wire obligation exact: a failed
encode changes nothing and a repeated call cannot emit a duplicate reset.

**Returns:** `H2SendResetResult`

<a id="H2ProtocolState-sendCancelFrame"></a>

### H2ProtocolState.sendCancelFrame

```vex
export fn (self: &H2ProtocolState!) sendCancelFrame(streamId: u32, out: &str!): H2SendResetResult
```

**Returns:** `H2SendResetResult`

<a id="H2ProtocolState-recvRstStreamFrame"></a>

### H2ProtocolState.recvRstStreamFrame

```vex
export fn (self: &H2ProtocolState!) recvRstStreamFrame(frame: &H2Frame, payload: str): H2ReceiveResetResult
```

Consume a peer RST_STREAM payload exactly once. Idle-stream violations,

connection sequencing and the four-byte payload are validated before the
stream state and scheduler capacity are published.

**Returns:** `H2ReceiveResetResult`

<a id="H2ProtocolState-markReady"></a>

### H2ProtocolState.markReady

```vex
export fn (self: &H2ProtocolState!) markReady(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-markBlocked"></a>

### H2ProtocolState.markBlocked

```vex
export fn (self: &H2ProtocolState!) markBlocked(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-completeWritable"></a>

### H2ProtocolState.completeWritable

```vex
export fn (self: &H2ProtocolState!) completeWritable(streamId: u32, stillReady: bool): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-nextWritable"></a>

### H2ProtocolState.nextWritable

```vex
export fn (self: &H2ProtocolState!) nextWritable(maximumBytes: u32): H2ScheduleResult
```

Select only work that has both application bytes and connection/stream

flow credit. The returned budget is capped by scheduler chunk policy and
both windows. Flow-blocked work remains pending and is skipped without
allocation until WINDOW_UPDATE wakes it.

**Returns:** `H2ScheduleResult`

<a id="H2ProtocolState-sendHeaderBlock"></a>

### H2ProtocolState.sendHeaderBlock

```vex
export fn (self: &H2ProtocolState!) sendHeaderBlock(streamId: u32, endStream: bool, headers: &Vec<HpackHeader>, out: &str!): H2SendHeaderResult
```

Encode one complete HEADERS field block. Semantic phase,

stream transition, connection sequencing, HPACK state and caller output
form one transaction. The returned allocation-free cursor fragments the
contiguous payload according to the peer's effective frame-size setting.

**Returns:** `H2SendHeaderResult`

<a id="H2ProtocolState-sendPushPromise"></a>

### H2ProtocolState.sendPushPromise

```vex
export fn (self: &H2ProtocolState!) sendPushPromise(carrierStreamId: u32, headers: &Vec<HpackHeader>, out: &str!): H2SendPushResult
```

Reserve and encode one server PUSH_PROMISE transactionally. Carrier state,

promised stream ID/slot, priority capacity, connection sequencing, HPACK
table and output either commit together or are all restored. The returned
cursor emits the four-byte promised ID before the first HPACK slice and then
uses CONTINUATION as required by the peer frame-size setting.

**Returns:** `H2SendPushResult`

<a id="H2ProtocolState-recvDataFrame"></a>

### H2ProtocolState.recvDataFrame

```vex
export fn (self: &H2ProtocolState!) recvDataFrame(frame: &H2Frame, payload: str): H2ReceiveDataResult
```

Consume one complete DATA payload under a single protocol owner. Payload

shape, connection sequencing, both flow-control windows and the stream
transition are staged before publication. Application bytes remain a
borrowed slice of `payload`; padding is never copied or exposed.

**Returns:** `H2ReceiveDataResult`

<a id="H2ProtocolState-sendDataFrame"></a>

### H2ProtocolState.sendDataFrame

```vex
export fn (self: &H2ProtocolState!) sendDataFrame(streamId: u32, dataBytes: u32, paddingBytes: u8, endStream: bool): H2SendDataResult
```

Commit one outbound DATA frame from the current scheduler lease. Caller

must reserve `9 + frame.length` transport bytes before invoking this method;
after `Ready`, the returned metadata and payload layout are infallible.

**Returns:** `H2SendDataResult`

<a id="H2ProtocolState-recvWindowUpdateFrame"></a>

### H2ProtocolState.recvWindowUpdateFrame

```vex
export fn (self: &H2ProtocolState!) recvWindowUpdateFrame(frame: &H2Frame, payload: str): H2ProtocolFrameResult
```

Apply a complete peer WINDOW_UPDATE transaction. Frame sequencing,

increment parsing, scoped overflow checks, stream state and scheduler
wakeup commit together; malformed connection updates make the owner
terminal, while stream-scoped failures retire only that stream.

**Returns:** `H2ProtocolFrameResult`

<a id="H2ProtocolState-sendWindowUpdateFrame"></a>

### H2ProtocolState.sendWindowUpdateFrame

```vex
export fn (self: &H2ProtocolState!) sendWindowUpdateFrame(streamId: u32, increment: u32, out: &str!): H2SendControlResult
```

Encode and record one locally emitted WINDOW_UPDATE atomically. `out` must

provide thirteen bytes; failed capacity, sequencing or window arithmetic
leaves protocol state and destination bytes unchanged.

**Returns:** `H2SendControlResult`

<a id="H2ProtocolState-recvPingFrame"></a>

### H2ProtocolState.recvPingFrame

```vex
export fn (self: &H2ProtocolState!) recvPingFrame(frame: &H2Frame, payload: str): H2ReceivePingResult
```

Consume one exact peer PING payload. ACKs remove only the matching bounded

local token; unmatched ACKs remain observable without killing a healthy
connection. Non-ACK payloads borrow the caller's bytes for zero-copy echo.

**Returns:** `H2ReceivePingResult`

<a id="H2ProtocolState-sendPingFrame"></a>

### H2ProtocolState.sendPingFrame

```vex
export fn (self: &H2ProtocolState!) sendPingFrame(opaqueData: str, out: &str!): H2SendPingResult
```

Emit a locally initiated PING and retain its opaque token until the peer's

exact ACK arrives. Duplicate tokens and bounded-capacity overflow fail
before output or connection state changes.

**Returns:** `H2SendPingResult`

<a id="H2ProtocolState-sendPingAckFrame"></a>

### H2ProtocolState.sendPingAckFrame

```vex
export fn (self: &H2ProtocolState!) sendPingAckFrame(opaqueData: str, out: &str!): H2SendPingResult
```

Echo a peer PING payload as ACK without consuming local outstanding-PING

capacity. `opaqueData` should be the borrowed `AckRequired` payload.

**Returns:** `H2SendPingResult`

<a id="H2ProtocolState-recvPriorityUpdateFrame"></a>

### H2ProtocolState.recvPriorityUpdateFrame

```vex
export fn (self: &H2ProtocolState!) recvPriorityUpdateFrame(frame: &H2Frame, payload: str): H2ReceivePriorityResult
```

Consume one complete peer PRIORITY_UPDATE. The raw Structured Fields value

never escapes this boundary: payload shape and RFC 9218 syntax are checked
before direction/CONTINUATION sequencing and scheduler state can commit.

**Returns:** `H2ReceivePriorityResult`

<a id="H2ProtocolState-sendPriorityUpdateFrame"></a>

### H2ProtocolState.sendPriorityUpdateFrame

```vex
export fn (self: &H2ProtocolState!) sendPriorityUpdateFrame(streamId: u32, priority: &H2Priority, out: &str!): H2SendPriorityResult
```

Encode one client PRIORITY_UPDATE and publish local connection sequencing

only after the complete frame fits. This signal changes the peer scheduler;
it deliberately does not mutate the local scheduler.

**Returns:** `H2SendPriorityResult`

<a id="H2ProtocolState-recvLegacyPriorityFrame"></a>

### H2ProtocolState.recvLegacyPriorityFrame

```vex
export fn (self: &H2ProtocolState!) recvLegacyPriorityFrame(frame: &H2Frame, payload: str): H2ReceiveLegacyPriorityResult
```

Consume one deprecated RFC 7540 PRIORITY frame for interoperability. It

never creates a stream and never feeds the RFC 9218 scheduler. Known live
streams retain the metadata as a fallback; idle/closed unknown IDs are
validated then ignored exactly without affecting stream state.

**Returns:** `H2ReceiveLegacyPriorityResult`

<a id="H2ProtocolState-sendLegacyPriorityFrame"></a>

### H2ProtocolState.sendLegacyPriorityFrame

```vex
export fn (self: &H2ProtocolState!) sendLegacyPriorityFrame(streamId: u32, priority: &H2LegacyPriority, out: &str!): H2SendControlResult
```

Emit deprecated PRIORITY only for explicit compatibility. The frame may

name an idle or closed stream, so local stream state is intentionally not
consulted or mutated.

**Returns:** `H2SendControlResult`

<a id="H2ProtocolState-recvStreamFrame"></a>

### H2ProtocolState.recvStreamFrame

```vex
export fn (self: &H2ProtocolState!) recvStreamFrame(frame: &H2Frame): H2ProtocolFrameResult
```

Apply a non-header stream frame. Header-bearing frames must use

`recvHeaderFrame`, which owns payload reassembly and HPACK lifetime.

**Returns:** `H2ProtocolFrameResult`

<a id="H2ProtocolState-sendStreamFrame"></a>

### H2ProtocolState.sendStreamFrame

```vex
export fn (self: &H2ProtocolState!) sendStreamFrame(frame: &H2Frame): H2ProtocolFrameResult
```

Apply a locally emitted frame transactionally. Invalid stream transitions

and connection sequencing errors commit neither side of the state machine.

**Returns:** `H2ProtocolFrameResult`

<a id="H2ProtocolState-recvConnectionFrame"></a>

### H2ProtocolState.recvConnectionFrame

```vex
export fn (self: &H2ProtocolState!) recvConnectionFrame(frame: &H2Frame): H2ConnectionResult
```

**Returns:** `H2ConnectionResult`

<a id="H2ProtocolState-sendConnectionFrame"></a>

### H2ProtocolState.sendConnectionFrame

```vex
export fn (self: &H2ProtocolState!) sendConnectionFrame(frame: &H2Frame): H2ConnectionResult
```

**Returns:** `H2ConnectionResult`

<a id="H2ProtocolState-recvSettingsFrame"></a>

### H2ProtocolState.recvSettingsFrame

```vex
export fn (self: &H2ProtocolState!) recvSettingsFrame(frame: &H2Frame, payload: str): H2ProtocolFrameResult
```

Receive and apply a peer SETTINGS frame. Non-ACK values become effective

before `SettingsAckRequired` is returned. ACK frames commit the oldest
queued local SETTINGS snapshot in FIFO order.

**Returns:** `H2ProtocolFrameResult`

<a id="H2ProtocolState-sendSettingsFrame"></a>

### H2ProtocolState.sendSettingsFrame

```vex
export fn (self: &H2ProtocolState!) sendSettingsFrame(frame: &H2Frame, payload: str): H2ProtocolFrameResult
```

Record a locally emitted SETTINGS frame. A non-ACK payload is merged onto

the newest queued snapshot and retained until the corresponding peer ACK;
local decoder/receive policy never changes early.

**Returns:** `H2ProtocolFrameResult`

<a id="H2ProtocolState-recvHeaderFrame"></a>

### H2ProtocolState.recvHeaderFrame

```vex
export fn (self: &H2ProtocolState!) recvHeaderFrame(frame: &H2Frame, payload: str): H2HeaderFrameResult
```

Process one received HEADERS/PUSH_PROMISE/CONTINUATION frame and its exact

payload under connection-owned HPACK lifetime. Fragment memory is bounded;
decoding happens only after END_HEADERS. Stream errors are reported only
after the complete block has advanced compression state.

**Returns:** `H2HeaderFrameResult`

<a id="H2ProtocolState-applyPeerInitialWindowSize"></a>

### H2ProtocolState.applyPeerInitialWindowSize

```vex
export fn (self: &H2ProtocolState!) applyPeerInitialWindowSize(newSize: u32): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-applyLocalInitialWindowSize"></a>

### H2ProtocolState.applyLocalInitialWindowSize

```vex
export fn (self: &H2ProtocolState!) applyLocalInitialWindowSize(newSize: u32): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-recvGoAwayFrame"></a>

### H2ProtocolState.recvGoAwayFrame

```vex
export fn (self: &H2ProtocolState!) recvGoAwayFrame(frame: &H2Frame, payload: str): H2ReceiveGoAwayResult
```

Consume one complete peer GOAWAY transaction. Payload/debug bytes remain

borrowed from the exact frame payload; sequencing, non-increasing boundary
and retry-safe local stream retirement commit together.

**Returns:** `H2ReceiveGoAwayResult`

<a id="H2ProtocolState-recvFrame"></a>

### H2ProtocolState.recvFrame

```vex
export fn (self: &H2ProtocolState!) recvFrame(frame: &H2Frame, payload: str): H2InboundFrameResult
```

Consume one complete frame returned by `parseH2FrameLimited`. This is the

transport-facing receive boundary: every known frame class reaches its
dedicated transactional owner, while unknown extensions are sequenced and
ignored without accidentally admitting or retiring a stream.

**Returns:** `H2InboundFrameResult`

<a id="H2ProtocolState-recvBytes"></a>

### H2ProtocolState.recvBytes

```vex
export fn (self: &H2ProtocolState!) recvBytes(input: str): H2IngressResult
```

Parse and dispatch at most one frame from caller-retained transport bytes.

Valid frames remain zero-copy: `NeedMore(0, n)` asks the caller to retain
the prefix, and `Dispatched(consumed, result)` permits compaction only after
borrowed result views have been handled. Stream-invalid frame payloads are
discarded incrementally through `ingress`, bounding hostile-frame memory.

**Returns:** `H2IngressResult`

<a id="H2ProtocolState-sendGoAwayFrame"></a>

### H2ProtocolState.sendGoAwayFrame

```vex
export fn (self: &H2ProtocolState!) sendGoAwayFrame(lastStreamId: u32, errorCode: u32, debugData: str, out: &str!): H2SendGoAwayResult
```

Encode and publish one local GOAWAY transaction. The output must reserve

`17 + debugData.len()` bytes first; failed capacity/sequencing/boundary
validation leaves connection, streams and scheduler unchanged.

**Returns:** `H2SendGoAwayResult`

<a id="H2ProtocolState-localStreamMayHaveBeenProcessed"></a>

### H2ProtocolState.localStreamMayHaveBeenProcessed

```vex
export fn (self: &H2ProtocolState) localStreamMayHaveBeenProcessed(streamId: u32): bool
```

**Returns:** `bool`

<a id="H2ProtocolState-abort"></a>

### H2ProtocolState.abort

```vex
export fn (self: &H2ProtocolState!) abort(errorCode: u32): H2ProtocolAbortResult
```

Terminate the entire protocol owner without freeing its reusable storage.

Every scheduler lease and active/idle priority record is revoked exactly
once; transport/task owners can then propagate `errorCode` to their waiters.

**Returns:** `H2ProtocolAbortResult`

<a id="HeaderEntry-empty"></a>

### HeaderEntry.empty

```vex
export fn HeaderEntry.empty(): HeaderEntry
```

**Returns:** `HeaderEntry`

<a id="ParserHeaders-new"></a>

### ParserHeaders.new

```vex
export fn ParserHeaders.new(): ParserHeaders
```

Create an empty header collection.

**Returns:** `ParserHeaders`

<a id="ParserHeaders-add"></a>

### ParserHeaders.add

```vex
export fn (self: &ParserHeaders!) add(name: str, value: str): bool
```

Add a header entry. Returns false if at capacity.

**Returns:** `bool`

<a id="ParserHeaders-get"></a>

### ParserHeaders.get

```vex
export fn (self: &ParserHeaders) get(name: str): str
```

Get header value by name (case-insensitive).

Returns first matching value, or empty str if not found.

**Returns:** `str`

<a id="ParserHeaders-has"></a>

### ParserHeaders.has

```vex
export fn (self: &ParserHeaders) has(name: str): bool
```

Check if a header exists (case-insensitive).

**Returns:** `bool`

<a id="ParserHeaders-messageFraming"></a>

### ParserHeaders.messageFraming

```vex
export fn (self: &ParserHeaders) messageFraming(): MessageFraming
```

Derive the unique HTTP body framing from the complete header collection.

This HTTP/1 layer accepts only the transfer coding it can decode itself:
one `chunked` field. Multiple Content-Length or Transfer-Encoding fields,
a comma-list, unsupported transfer coding, or both framing mechanisms are
rejected rather than silently choosing a different boundary than a proxy.

**Returns:** `MessageFraming`

<a id="ParserHeaders-contentLength"></a>

### ParserHeaders.contentLength

```vex
export fn (self: &ParserHeaders) contentLength(): i64
```

Get Content-Length value, or -1 when no unambiguous content length exists.

New framing-sensitive code should use `messageFraming()` directly.

**Returns:** `i64`

<a id="ParserHeaders-isChunked"></a>

### ParserHeaders.isChunked

```vex
export fn (self: &ParserHeaders) isChunked(): bool
```

True only when the complete message framing is exactly chunked.

**Returns:** `bool`

<a id="ParserHeaders-isConnectionClose"></a>

### ParserHeaders.isConnectionClose

```vex
export fn (self: &ParserHeaders) isConnectionClose(): bool
```

Check whether any Connection token says `close`.

**Returns:** `bool`

<a id="ParserHeaders-isUpgrade"></a>

### ParserHeaders.isUpgrade

```vex
export fn (self: &ParserHeaders) isUpgrade(): bool
```

Check whether any Connection token says `upgrade`.

**Returns:** `bool`

<a id="ParserHeaders-len"></a>

### ParserHeaders.len

```vex
export fn (self: &ParserHeaders) len(): usize
```

Get number of stored headers.

**Returns:** `usize`

<a id="ParserHeaders-clear"></a>

### ParserHeaders.clear

```vex
export fn (self: &ParserHeaders!) clear()
```

Reset the header collection for reuse.

**Receiver:** `self: &ParserHeaders!` *(mutable reference)*

<a id="ParserHeaders-at"></a>

### ParserHeaders.at

```vex
export fn (self: &ParserHeaders) at(index: usize): HeaderEntry
```

Get header entry by index.

**Returns:** `HeaderEntry`

<a id="DynamicTable-new"></a>

### DynamicTable.new

```vex
export fn DynamicTable.new(maxSize: usize): DynamicTable
```

**Returns:** `DynamicTable`

<a id="DynamicTable-add"></a>

### DynamicTable.add

```vex
export fn (self: &DynamicTable!) add(name: string, value: string)
```

Add entry to dynamic table (front = newest).

<a id="DynamicTable-lookup"></a>

### DynamicTable.lookup

```vex
export fn (self: &DynamicTable) lookup(index: usize): (string, string)
```

Look up by absolute index (1-based, 1..61 = static, 62+ = dynamic).

**Returns:** `(string, string)`

<a id="DynamicTable-setMaxSize"></a>

### DynamicTable.setMaxSize

```vex
export fn (self: &DynamicTable!) setMaxSize(newMax: usize): bool
```

Update max size (from SETTINGS_HEADER_TABLE_SIZE).

**Returns:** `bool`

<a id="DynamicTable-setAllowedMaxSize"></a>

### DynamicTable.setAllowedMaxSize

```vex
export fn (self: &DynamicTable!) setAllowedMaxSize(newMaximum: usize)
```

Apply an acknowledged SETTINGS_HEADER_TABLE_SIZE to the decoder. A

reduction below the encoder's currently declared table size does not evict
immediately: the peer must begin its next field block with the HPACK size
update that performs the synchronized eviction.

<a id="DynamicTable-requiresSizeUpdate"></a>

### DynamicTable.requiresSizeUpdate

```vex
export fn (self: &DynamicTable) requiresSizeUpdate(): bool
```

**Returns:** `bool`

<a id="HpackHeader-new"></a>

### HpackHeader.new

```vex
export fn HpackHeader.new(name: str, value: str): HpackHeader
```

**Returns:** `HpackHeader`

<a id="HpackHeader-withIndexing"></a>

### HpackHeader.withIndexing

```vex
export fn HpackHeader.withIndexing(name: str, value: str, indexing: HpackIndexing): HpackHeader
```

**Returns:** `HpackHeader`

<a id="HpackHeader-sensitive"></a>

### HpackHeader.sensitive

```vex
export fn HpackHeader.sensitive(name: str, value: str): HpackHeader
```

**Returns:** `HpackHeader`

<a id="HpackDecodeLimits-defaults"></a>

### HpackDecodeLimits.defaults

```vex
export fn HpackDecodeLimits.defaults(): HpackDecodeLimits
```

**Returns:** `HpackDecodeLimits`

<a id="HpackDecodeLimits-isValid"></a>

### HpackDecodeLimits.isValid

```vex
export fn (self: &HpackDecodeLimits) isValid(): bool
```

**Returns:** `bool`

<a id="HpackEncodeLimits-defaults"></a>

### HpackEncodeLimits.defaults

```vex
export fn HpackEncodeLimits.defaults(): HpackEncodeLimits
```

**Returns:** `HpackEncodeLimits`

<a id="HpackEncodeLimits-isValid"></a>

### HpackEncodeLimits.isValid

```vex
export fn (self: &HpackEncodeLimits) isValid(): bool
```

**Returns:** `bool`

<a id="HpackEncoder-new"></a>

### HpackEncoder.new

```vex
export fn HpackEncoder.new(maximumTableBytes: usize): HpackEncoder
```

**Returns:** `HpackEncoder`

<a id="HpackEncoder-dynamicTableBytes"></a>

### HpackEncoder.dynamicTableBytes

```vex
export fn (self: &HpackEncoder) dynamicTableBytes(): usize
```

**Returns:** `usize`

<a id="HpackEncoder-maximumTableBytes"></a>

### HpackEncoder.maximumTableBytes

```vex
export fn (self: &HpackEncoder) maximumTableBytes(): usize
```

**Returns:** `usize`

<a id="HpackEncoder-hasPendingSizeUpdate"></a>

### HpackEncoder.hasPendingSizeUpdate

```vex
export fn (self: &HpackEncoder) hasPendingSizeUpdate(): bool
```

**Returns:** `bool`

<a id="HpackEncoder-setMaximumTableBytes"></a>

### HpackEncoder.setMaximumTableBytes

```vex
export fn (self: &HpackEncoder!) setMaximumTableBytes(maximum: usize)
```

Apply the peer's effective SETTINGS_HEADER_TABLE_SIZE. No wire state is

consumed until a field block is successfully encoded.

<a id="MultipartLimits-defaults"></a>

### MultipartLimits.defaults

```vex
export fn MultipartLimits.defaults(): MultipartLimits
```

**Returns:** `MultipartLimits`

<a id="Method-asStr"></a>

### Method.asStr

```vex
export fn (self: &Method) asStr(): str
```

Method to string.

**Returns:** `str`

<a id="HttpVersion-asStr"></a>

### HttpVersion.asStr

```vex
export fn (self: &HttpVersion) asStr(): str
```

**Returns:** `str`

<a id="ParserRequest-empty"></a>

### ParserRequest.empty

```vex
export fn ParserRequest.empty(): ParserRequest
```

Create an empty request.

**Returns:** `ParserRequest`

<a id="ParserRequest-path"></a>

### ParserRequest.path

```vex
export fn (self: &ParserRequest) path(): str
```

Get the URI path component (before '?').

**Returns:** `str`

<a id="ParserRequest-query"></a>

### ParserRequest.query

```vex
export fn (self: &ParserRequest) query(): str
```

Get query string (after '?'), or empty.

**Returns:** `str`

<a id="ParserRequest-host"></a>

### ParserRequest.host

```vex
export fn (self: &ParserRequest) host(): str
```

Get Host header value.

**Returns:** `str`

<a id="ParserRequest-contentLength"></a>

### ParserRequest.contentLength

```vex
export fn (self: &ParserRequest) contentLength(): i64
```

Get Content-Length or -1.

**Returns:** `i64`

<a id="ParserRequest-isChunked"></a>

### ParserRequest.isChunked

```vex
export fn (self: &ParserRequest) isChunked(): bool
```

Is this a chunked transfer?

**Returns:** `bool`

<a id="ParserRequest-isWebSocketUpgrade"></a>

### ParserRequest.isWebSocketUpgrade

```vex
export fn (self: &ParserRequest) isWebSocketUpgrade(): bool
```

Is this a WebSocket upgrade?

**Returns:** `bool`

<a id="ParserRequest-hasBody"></a>

### ParserRequest.hasBody

```vex
export fn (self: &ParserRequest) hasBody(): bool
```

Does the request expect a body?

**Returns:** `bool`

<a id="Response-empty"></a>

### Response.empty

```vex
export fn Response.empty(): Response
```

Create an empty response.

**Returns:** `Response`

<a id="Response-isInformational"></a>

### Response.isInformational

```vex
export fn (self: &Response) isInformational(): bool
```

True if status is 1xx (informational).

**Returns:** `bool`

<a id="Response-isSuccess"></a>

### Response.isSuccess

```vex
export fn (self: &Response) isSuccess(): bool
```

True if status is 2xx (success).

**Returns:** `bool`

<a id="Response-isRedirect"></a>

### Response.isRedirect

```vex
export fn (self: &Response) isRedirect(): bool
```

True if status is 3xx (redirect).

**Returns:** `bool`

<a id="Response-isClientError"></a>

### Response.isClientError

```vex
export fn (self: &Response) isClientError(): bool
```

True if status is 4xx (client error).

**Returns:** `bool`

<a id="Response-isServerError"></a>

### Response.isServerError

```vex
export fn (self: &Response) isServerError(): bool
```

True if status is 5xx (server error).

**Returns:** `bool`

<a id="Response-contentLength"></a>

### Response.contentLength

```vex
export fn (self: &Response) contentLength(): i64
```

Get Content-Length or -1.

**Returns:** `i64`

<a id="Response-isChunked"></a>

### Response.isChunked

```vex
export fn (self: &Response) isChunked(): bool
```

Is chunked transfer?

**Returns:** `bool`

<a id="Response-isConnectionClose"></a>

### Response.isConnectionClose

```vex
export fn (self: &Response) isConnectionClose(): bool
```

Is Connection: close?

**Returns:** `bool`

<a id="Response-location"></a>

### Response.location

```vex
export fn (self: &Response) location(): str
```

Get Location header (for redirects).

**Returns:** `str`

<a id="Response-contentType"></a>

### Response.contentType

```vex
export fn (self: &Response) contentType(): str
```

Get Content-Type header.

**Returns:** `str`

<a id="Scanner-new"></a>

### Scanner.new

```vex
export fn Scanner.new(input: str): Scanner
```

Create a scanner over the given input.

**Returns:** `Scanner`

<a id="Scanner-at"></a>

### Scanner.at

```vex
export fn Scanner.at(input: str, offset: usize): Scanner
```

Create a scanner starting at a given offset.

**Returns:** `Scanner`

<a id="Scanner-remaining"></a>

### Scanner.remaining

```vex
export fn (self: &Scanner) remaining(): usize
```

Bytes remaining from current position.

**Returns:** `usize`

<a id="Scanner-isEof"></a>

### Scanner.isEof

```vex
export fn (self: &Scanner) isEof(): bool
```

True if no bytes remain.

**Returns:** `bool`

<a id="Scanner-position"></a>

### Scanner.position

```vex
export fn (self: &Scanner) position(): usize
```

Current absolute cursor position.

**Returns:** `usize`

<a id="Scanner-setPosition"></a>

### Scanner.setPosition

```vex
export fn (self: &Scanner!) setPosition(newPos: usize)
```

Set absolute cursor position (clamped to input length).

<a id="Scanner-peek"></a>

### Scanner.peek

```vex
export fn (self: &Scanner) peek(): u8
```

Peek at byte at current position (0 if EOF).

**Returns:** `u8`

<a id="Scanner-peekAt"></a>

### Scanner.peekAt

```vex
export fn (self: &Scanner) peekAt(offset: usize): u8
```

Peek at byte at offset from current position.

**Returns:** `u8`

<a id="Scanner-advance"></a>

### Scanner.advance

```vex
export fn (self: &Scanner!) advance(n: usize)
```

Advance position by n bytes.

<a id="Scanner-rest"></a>

### Scanner.rest

```vex
export fn (self: &Scanner) rest(): str
```

Get a str slice from current position to end.

**Returns:** `str`

<a id="Scanner-slice"></a>

### Scanner.slice

```vex
export fn (self: &Scanner) slice(start: usize, end: usize): str
```

Get a str slice [start..end) relative to buffer start.

**Returns:** `str`

<a id="Scanner-findByte"></a>

### Scanner.findByte

```vex
export fn (self: &Scanner) findByte(byt: u8): usize
```

Find first occurrence of `byte` from current position.

Returns absolute index into buffer, or `Limits.usizeMax` if not found.
Uses SIMD comparison for buffers &gt;= 16 bytes, scalar for short.

**Returns:** `usize`

<a id="Scanner-findCRLF"></a>

### Scanner.findCRLF

```vex
export fn (self: &Scanner) findCRLF(): usize
```

Find \r\n (CRLF) from current position.

Returns absolute index of \r, or `Limits.usizeMax` if not found.
SIMD: scan for \r, then verify \n follows.

**Returns:** `usize`

<a id="Scanner-findDoubleCRLF"></a>

### Scanner.findDoubleCRLF

```vex
export fn (self: &Scanner) findDoubleCRLF(): usize
```

Find \r\n\r\n (double CRLF — end of headers).

Returns absolute index of first \r, or `Limits.usizeMax` if not found.
Strategy: SIMD scan for \r, then verify \n\r\n pattern.

**Returns:** `usize`

<a id="Scanner-readUntil"></a>

### Scanner.readUntil

```vex
export fn (self: &Scanner!) readUntil(delim: u8): str
```

Read bytes until `delim` is found. Returns slice [pos..delim_pos).

Advances past the delimiter.
Returns empty str and does NOT advance if delimiter not found.

**Returns:** `str`

<a id="Scanner-readLine"></a>

### Scanner.readLine

```vex
export fn (self: &Scanner!) readLine(): str
```

Read bytes until CRLF. Returns slice [pos..cr_pos).

Advances past the \r\n.
Returns empty str if CRLF not found (incomplete).

**Returns:** `str`

<a id="Scanner-expect"></a>

### Scanner.expect

```vex
export fn (self: &Scanner!) expect(byt: u8): bool
```

Expect and consume a specific byte. Returns true if matched.

**Returns:** `bool`

<a id="Scanner-skipOWS"></a>

### Scanner.skipOWS

```vex
export fn (self: &Scanner!) skipOWS()
```

Skip optional whitespace (SP and HTAB).

**Receiver:** `self: &Scanner!` *(mutable reference)*

<a id="Scanner-skipSP"></a>

### Scanner.skipSP

```vex
export fn (self: &Scanner!) skipSP(): bool
```

Skip exactly one SP (space). Returns true if consumed.

**Returns:** `bool`

<a id="Scanner-readN"></a>

### Scanner.readN

```vex
export fn (self: &Scanner!) readN(n: usize): str
```

Read a fixed number of bytes as a str slice.

**Returns:** `str`

<a id="Scanner-startsWith"></a>

### Scanner.startsWith

```vex
export fn (self: &Scanner) startsWith(pattern: str): bool
```

Check if the next bytes match a pattern (case-sensitive).

Does NOT advance the position.

**Returns:** `bool`

<a id="StreamState-name"></a>

### StreamState.name

```vex
export fn (self: &StreamState) name(): str
```

Human-readable state name.

**Returns:** `str`

<a id="H2Stream-new"></a>

### H2Stream.new

```vex
export fn H2Stream.new(id: u32, initialWindow: i32): H2Stream
```

Create a new stream in idle state.

**Returns:** `H2Stream`

<a id="H2Stream-recvFrame"></a>

### H2Stream.recvFrame

```vex
export fn (self: &H2Stream!) recvFrame(frame: &H2Frame): StreamError
```

Process a received frame and transition state.

Returns StreamError indicating if the transition is valid.

**Returns:** `StreamError`

<a id="H2Stream-sendFrame"></a>

### H2Stream.sendFrame

```vex
export fn (self: &H2Stream!) sendFrame(frame: &H2Frame): StreamError
```

Process a sent frame and transition state.

**Returns:** `StreamError`

<a id="H2Stream-setLegacyPriority"></a>

### H2Stream.setLegacyPriority

```vex
export fn (self: &H2Stream!) setLegacyPriority(dep: u32, weight: u16, exclusive: bool): bool
```

Retain deprecated RFC 7540 dependency metadata for interoperability fallback.

New scheduling uses RFC 9218 `H2PriorityScheduler`.

**Returns:** `bool`

<a id="H2Stream-isClosed"></a>

### H2Stream.isClosed

```vex
export fn (self: &H2Stream) isClosed(): bool
```

Is the stream in a terminal state?

**Returns:** `bool`

<a id="H2Stream-canSend"></a>

### H2Stream.canSend

```vex
export fn (self: &H2Stream) canSend(): bool
```

Can this stream send DATA/HEADERS?

**Returns:** `bool`

<a id="H2Stream-canRecv"></a>

### H2Stream.canRecv

```vex
export fn (self: &H2Stream) canRecv(): bool
```

Can this stream receive DATA/HEADERS?

**Returns:** `bool`

<a id="StreamMap-new"></a>

### StreamMap.new

```vex
export fn StreamMap.new(maxStreams: u32): StreamMap
```

Create a stream map with RFC default send/receive windows. Negotiated

SETTINGS are applied transactionally through the directional methods below.

**Returns:** `StreamMap`

<a id="StreamMap-find"></a>

### StreamMap.find

```vex
export fn (self: &StreamMap) find(id: u32): i32
```

Find a materialized stream without changing connection state.

**Returns:** `i32`

<a id="StreamMap-getOrCreate"></a>

### StreamMap.getOrCreate

```vex
export fn (self: &StreamMap!) getOrCreate(id: u32): i32
```

Get or create a stream by ID.

**Returns:** `i32`

<a id="StreamMap-residentCount"></a>

### StreamMap.residentCount

```vex
export fn (self: &StreamMap) residentCount(): usize
```

Number of resident slots. This never exceeds the configured concurrent

bound even after arbitrarily many sequential streams.

**Returns:** `usize`

<a id="StreamMap-applyPeerInitialWindowSize"></a>

### StreamMap.applyPeerInitialWindowSize

```vex
export fn (self: &StreamMap!) applyPeerInitialWindowSize(newSize: u32): bool
```

Apply peer SETTINGS_INITIAL_WINDOW_SIZE to every local send window.

A decrease may legally make an existing stream window negative.

**Returns:** `bool`

<a id="StreamMap-applyLocalInitialWindowSize"></a>

### StreamMap.applyLocalInitialWindowSize

```vex
export fn (self: &StreamMap!) applyLocalInitialWindowSize(newSize: u32): bool
```

Apply a locally advertised SETTINGS_INITIAL_WINDOW_SIZE to receive windows.

**Returns:** `bool`

<a id="StreamMap-get"></a>

### StreamMap.get

```vex
export fn (self: &StreamMap) get(index: usize): Option<H2Stream>
```

Get stream by index.

**Returns:** `Option<H2Stream>`

<a id="StreamMap-activeCount"></a>

### StreamMap.activeCount

```vex
export fn (self: &StreamMap) activeCount(): u32
```

Count active (non-closed) streams.

**Returns:** `u32`

<a id="WsFrame-isControl"></a>

### WsFrame.isControl

```vex
export fn (self: &WsFrame) isControl(): bool
```

Is this a control frame? (opcodes 0x8-0xF)

**Returns:** `bool`

<a id="WsFrame-isText"></a>

### WsFrame.isText

```vex
export fn (self: &WsFrame) isText(): bool
```

Is this a text frame?

**Returns:** `bool`

<a id="WsFrame-isBinary"></a>

### WsFrame.isBinary

```vex
export fn (self: &WsFrame) isBinary(): bool
```

Is this a binary frame?

**Returns:** `bool`

<a id="WsFrame-isClose"></a>

### WsFrame.isClose

```vex
export fn (self: &WsFrame) isClose(): bool
```

Is this a close frame?

**Returns:** `bool`

<a id="WsFrame-isPing"></a>

### WsFrame.isPing

```vex
export fn (self: &WsFrame) isPing(): bool
```

Is this a ping frame?

**Returns:** `bool`

<a id="WsFrame-isPong"></a>

### WsFrame.isPong

```vex
export fn (self: &WsFrame) isPong(): bool
```

Is this a pong frame?

**Returns:** `bool`

<a id="WsMessage-new"></a>

### WsMessage.new

```vex
export fn WsMessage.new(): WsMessage
```

**Returns:** `WsMessage`

<a id="WsMessage-feedFrame"></a>

### WsMessage.feedFrame

```vex
export fn (self: &WsMessage!) feedFrame(frame: &WsFrame, payload: str): bool
```

Feed a parsed frame into the message assembler.

For single-frame messages, returns immediately.
For fragmented messages, accumulates until FIN.

**Returns:** `bool`

<a id="WsMessage-reset"></a>

### WsMessage.reset

```vex
export fn (self: &WsMessage!) reset()
```

Reset for next message.

**Receiver:** `self: &WsMessage!` *(mutable reference)*

<a id="Request-invalid"></a>

### Request.invalid

```vex
export fn Request.invalid(): Request
```

Empty/invalid request sentinel.

**Returns:** `Request`

<a id="Request-header"></a>

### Request.header

```vex
export fn (self: &Request) header(name: str): str
```

Get a header value by name (case-insensitive). Returns empty str if absent.

**Returns:** `str`

<a id="Request-hasHeader"></a>

### Request.hasHeader

```vex
export fn (self: &Request) hasHeader(name: str): bool
```

Check if a header exists.

**Returns:** `bool`

<a id="Request-isMethod"></a>

### Request.isMethod

```vex
export fn (self: &Request) isMethod(m: str): bool
```

Check if the request method matches (case-sensitive).

**Returns:** `bool`

<a id="Request-hasBody"></a>

### Request.hasBody

```vex
export fn (self: &Request) hasBody(): bool
```

Check if the request has a body.

**Returns:** `bool`

<a id="Request-contentType"></a>

### Request.contentType

```vex
export fn (self: &Request) contentType(): str
```

Get Content-Type header.

**Returns:** `str`

<a id="Request-isJSON"></a>

### Request.isJSON

```vex
export fn (self: &Request) isJSON(): bool
```

Check if request is JSON.

**Returns:** `bool`

<a id="Response-new"></a>

### Response.new

```vex
export fn Response.new(): Response
```

Create a new response with default 200 OK and keep-alive.

**Returns:** `Response`

<a id="Response-takeStreamHead"></a>

### Response.takeStreamHead

```vex
export fn! (self: &Response!) takeStreamHead(): ResponseStreamHead
```

Move streaming response metadata exactly once. Header vectors retain their

allocations and are not cloned across the task/transport boundary.

**Returns:** `ResponseStreamHead`

<a id="Response-reset"></a>

### Response.reset

```vex
export fn (self: &Response!) reset()
```

Reset response for reuse (clears headers, keeps capacity).

**Receiver:** `self: &Response!` *(mutable reference)*

<a id="Response-status"></a>

### Response.status

```vex
export fn (self: &Response!) status(code: i32): &Response!
```

**Returns:** `&Response!`

<a id="Response-header"></a>

### Response.header

```vex
export fn (self: &Response!) header(name: string, value: string): &Response!
```

**Returns:** `&Response!`

<a id="Response-contentType-2"></a>

### Response.contentType

```vex
export fn (self: &Response!) contentType(ct: string): &Response!
```

**Returns:** `&Response!`

<a id="Response-setBody"></a>

### Response.setBody

```vex
export fn (self: &Response!) setBody(b: string): &Response!
```

**Returns:** `&Response!`

<a id="Response-sendString"></a>

### Response.sendString

```vex
export fn (self: &Response!) sendString(fd: i64, text: string)
```

<a id="Response-sendJSON"></a>

### Response.sendJSON

```vex
export fn (self: &Response!) sendJSON(fd: i64, json: string)
```

<a id="Response-sendHTML"></a>

### Response.sendHTML

```vex
export fn (self: &Response!) sendHTML(fd: i64, html: string)
```

<a id="Response-send"></a>

### Response.send

```vex
export fn (self: &Response!) send(fd: i64)
```

<a id="Response-sendEmpty"></a>

### Response.sendEmpty

```vex
export fn (self: &Response!) sendEmpty(fd: i64)
```

<a id="Response-appendEncodedTo"></a>

### Response.appendEncodedTo

```vex
export fn (self: &Response) appendEncodedTo(out: &StringBuilder!)
```

Append the buffered Fiber response into caller-owned reusable storage.

`sendString`/`sendJSON`/`sendHTML` preserve their implicit content type;
a plain `send` uses only explicitly set headers. The method does not reset
`out`, so a server can coalesce complete HTTP responses before one socket
write.

<a id="Response-appendStreamHeadersTo"></a>

### Response.appendStreamHeadersTo

```vex
export fn (self: &Response) appendStreamHeadersTo(out: &StringBuilder!, bodyLength: u64): bool
```

Append only the HTTP/1 headers for a body that Fiber will stream directly

after its ordered response queue drains. The body length is mandatory:
HTTP/1 keep-alive cannot safely infer a streamed body boundary.

**Returns:** `bool`

<a id="Response-appendChunkedHeadersTo"></a>

### Response.appendChunkedHeadersTo

```vex
export fn (self: &Response) appendChunkedHeadersTo(out: &StringBuilder!): bool
```

Append headers for an unknown-length HTTP/1 response body.

A writable dynamic body uses chunked transfer coding. For HEAD, the
representation length is unknown and must not be invented as zero, so the
response deliberately omits both framing fields and returns false. For a
status that forbids content, the ordinary zero-length framing is retained.

**Returns:** `bool`

<a id="Response-appendChunkTo"></a>

### Response.appendChunkTo

```vex
export fn (self: &Response) appendChunkTo(out: &StringBuilder!, data: str)
```

<a id="Response-appendChunkTerminatorTo"></a>

### Response.appendChunkTerminatorTo

```vex
export fn (self: &Response) appendChunkTerminatorTo(out: &StringBuilder!)
```

<a id="Response-encode"></a>

### Response.encode

```vex
export fn (self: &Response!) encode(): str
```

Serialize into response-owned reusable storage and borrow the encoded bytes.

The returned view remains valid until this Response is mutated or reset.

**Returns:** `str`

<a id="Server-new"></a>

### Server.new

```vex
export fn Server.new(host: string, port: i32): Server
```

Create a direct callback server with Fiber's production defaults.

Binding, worker creation and socket ownership begin in `serve`.

**Returns:** `Server`

<a id="Server-withConfig"></a>

### Server.withConfig

```vex
export fn Server.withConfig(host: string, port: i32, config: AppConfig): Server
```

Create a direct callback server with one coherent Fiber resource policy.

**Returns:** `Server`

<a id="Server-serve"></a>

### Server.serve

```vex
export fn (self: Server) serve(handler: RequestHandler)
```

Serve requests through the canonical Fiber HTTP/1 state machine.

Use `App` directly when routes or middleware are required. This callback
form remains useful for compact protocol endpoints without maintaining a
separate server implementation.

<a id="Server-serveWithContext"></a>

### Server.serveWithContext

```vex
export fn (self: Server) serveWithContext(lifetime: Context, handler: RequestHandler)
```

Context-cancellable direct callback server. Cancellation has the same

descriptor cleanup and worker-join semantics as `App.listenWithContext`.

<a id="WsSession-new"></a>

### WsSession.new

```vex
export fn WsSession.new(fd: i64): WsSession
```

Create a session for an already non-blocking, already-upgraded socket.

`fd < 0` produces a fail-closed inert session useful for tests/adapters.

**Returns:** `WsSession`

<a id="WsSession-withId"></a>

### WsSession.withId

```vex
export fn WsSession.withId(fd: i64, id: u64): WsSession
```

Create a session with a stable application-visible identity. Low-level

adapters use zero; Fiber assigns a nonzero process-local id at handoff.

**Returns:** `WsSession`

<a id="WsSession-withIdAndProtocol"></a>

### WsSession.withIdAndProtocol

```vex
export fn WsSession.withIdAndProtocol(fd: i64, id: u64, protocol: string): WsSession
```

Create an upgraded session with the one route-selected subprotocol. The

value is immutable after construction and is exposed to lifecycle/message
callbacks without consulting HTTP headers again.

**Returns:** `WsSession`

<a id="WsSession-isOpen"></a>

### WsSession.isOpen

```vex
export fn (self: &WsSession) isOpen(): bool
```

**Returns:** `bool`

<a id="WsSession-id"></a>

### WsSession.id

```vex
export fn (self: &WsSession) id(): u64
```

**Returns:** `u64`

<a id="WsSession-protocol"></a>

### WsSession.protocol

```vex
export fn (self: &WsSession) protocol(): str
```

The negotiated RFC 6455 subprotocol, or empty when none was selected.

**Returns:** `str`

<a id="WsSession-pendingInput"></a>

### WsSession.pendingInput

```vex
export fn (self: &WsSession) pendingInput(): usize
```

**Returns:** `usize`

<a id="WsSession-pendingOutput"></a>

### WsSession.pendingOutput

```vex
export fn (self: &WsSession) pendingOutput(): usize
```

**Returns:** `usize`

<a id="WsSession-wantsWrite"></a>

### WsSession.wantsWrite

```vex
export fn (self: &WsSession) wantsWrite(): bool
```

**Returns:** `bool`

<a id="WsSession-shouldCloseAfterFlush"></a>

### WsSession.shouldCloseAfterFlush

```vex
export fn (self: &WsSession) shouldCloseAfterFlush(): bool
```

A close response may be queued behind earlier application output. The

worker must keep writable interest until it drains, then retire the fd.

**Returns:** `bool`

<a id="WsSession-stageInitialInput"></a>

### WsSession.stageInitialInput

```vex
export fn (self: &WsSession!) stageInitialInput(data: Ptr<u8>, len: usize): bool
```

Copy HTTP's already-received post-upgrade suffix into the session. This is

the handoff seam that preserves a WebSocket frame coalesced with the HTTP
request; it is all-or-nothing under the same input bound as socket reads.

**Returns:** `bool`

<a id="WsSession-readFromTransport"></a>

### WsSession.readFromTransport

```vex
export fn (self: &WsSession!) readFromTransport(): i64
```

Fill the common bounded input queue after an EVT_READ notification.

Positive = bytes read, zero = peer EOF, negative = native error/EAGAIN.

**Returns:** `i64`

<a id="WsSession-flushTransport"></a>

### WsSession.flushTransport

```vex
export fn (self: &WsSession!) flushTransport(): i64
```

Drain queued output after an EVT_WRITE notification. A negative EAGAIN is

intentionally propagated so the worker can retain writable interest;
non-retryable errors are owned by the worker's close policy.

**Returns:** `i64`

<a id="WsSession-sendText"></a>

### WsSession.sendText

```vex
export fn (self: &WsSession!) sendText(text: str): bool
```

**Returns:** `bool`

<a id="WsSession-sendBinary"></a>

### WsSession.sendBinary

```vex
export fn (self: &WsSession!) sendBinary(data: Ptr<u8>, len: usize): bool
```

**Returns:** `bool`

<a id="WsSession-sendPing"></a>

### WsSession.sendPing

```vex
export fn (self: &WsSession!) sendPing(data: str): bool
```

**Returns:** `bool`

<a id="WsSession-sendPong"></a>

### WsSession.sendPong

```vex
export fn (self: &WsSession!) sendPong(data: Ptr<u8>, len: usize): bool
```

**Returns:** `bool`

<a id="WsSession-closeWith"></a>

### WsSession.closeWith

```vex
export fn (self: &WsSession!) closeWith(data: Ptr<u8>, len: usize): bool
```

Queue a close payload once. The session remains drainable so a valid close

reply can reach the peer before the Fiber worker retires the descriptor.

**Returns:** `bool`

<a id="WsSession-close"></a>

### WsSession.close

```vex
export fn (self: &WsSession!) close(): bool
```

**Returns:** `bool`

<a id="WsSession-advanceFrame"></a>

### WsSession.advanceFrame

```vex
export fn (self: &WsSession!) advanceFrame(message: &WsMessage!): i32
```

**Returns:** `i32`

<a id="WsSession-nextMessage"></a>

### WsSession.nextMessage

```vex
export fn (self: &WsSession!) nextMessage(): Option<WsMessage>
```

Consume buffered frames until an application-visible message is available.

This compatibility helper intentionally preserves the simple polling API;
Fiber itself uses `advanceFrame` so its worker turn has a finite budget.

**Returns:** `Option<WsMessage>`

<a id="WsMessage-isText"></a>

### WsMessage.isText

```vex
export fn (self: &WsMessage) isText(): bool
```

Check if this is a text message.

**Returns:** `bool`

<a id="WsMessage-isBinary"></a>

### WsMessage.isBinary

```vex
export fn (self: &WsMessage) isBinary(): bool
```

Check if this is a binary message.

**Returns:** `bool`

<a id="WsMessage-isClose"></a>

### WsMessage.isClose

```vex
export fn (self: &WsMessage) isClose(): bool
```

Check if this is a close frame.

**Returns:** `bool`

<a id="WsMessage-isPing"></a>

### WsMessage.isPing

```vex
export fn (self: &WsMessage) isPing(): bool
```

Check if this is a ping frame.

**Returns:** `bool`

<a id="WsMessage-text"></a>

### WsMessage.text

```vex
export fn (self: &WsMessage) text(): string
```

Return an independent owned copy of the text content (for text messages).

Use `message.data.asStr()` for a borrowed, allocation-free view.

**Returns:** `string`

<a id="WsConn-new"></a>

### WsConn.new

```vex
export fn WsConn.new(fd: i64): WsConn
```

Create a WebSocket connection from an already-upgraded socket fd.

**Returns:** `WsConn`

<a id="WsConn-upgrade"></a>

### WsConn.upgrade

```vex
export fn WsConn.upgrade(fd: i64, req: &Request): WsConn
```

Perform the WebSocket upgrade handshake.

Sends the HTTP 101 Switching Protocols response.
The request must have the WebSocket upgrade headers.

**Returns:** `WsConn`

<a id="WsConn-sendText"></a>

### WsConn.sendText

```vex
export fn (self: &WsConn!) sendText(text: string)
```

Send a text message.

<a id="WsConn-sendBinary"></a>

### WsConn.sendBinary

```vex
export fn (self: &WsConn!) sendBinary(data: Ptr<u8>, len: u64)
```

Send a binary message.

<a id="WsConn-sendPing"></a>

### WsConn.sendPing

```vex
export fn (self: &WsConn!) sendPing()
```

Send a ping frame.

**Receiver:** `self: &WsConn!` *(mutable reference)*

<a id="WsConn-sendPong"></a>

### WsConn.sendPong

```vex
export fn (self: &WsConn!) sendPong()
```

Send a pong frame (response to ping).

**Receiver:** `self: &WsConn!` *(mutable reference)*

<a id="WsConn-close"></a>

### WsConn.close

```vex
export fn (self: &WsConn!) close()
```

Send a close frame and mark connection as closed.

**Receiver:** `self: &WsConn!` *(mutable reference)*

<a id="WsConn-readMessage"></a>

### WsConn.readMessage

```vex
export fn (self: &WsConn!) readMessage(): Option<WsMessage>
```

Read the next complete logical WebSocket message.

TCP read boundaries are unrelated to RFC 6455 frame boundaries: this method
retains suffix bytes, waits for a complete frame, unmasks client payloads,
responds to pings with the same payload, and joins continuation frames.
`None` means EOF, transport failure, malformed client input, or the bounded
message limit; each of those permanently closes this descriptor helper.

**Returns:** `Option<WsMessage>`

<a id="WsConn-messageLoop"></a>

### WsConn.messageLoop

```vex
export fn (self: &WsConn!) messageLoop(handler: fn (msg: WsMessage))
```

Run a message loop. Calls the handler for each received message.

Blocks until the connection closes.
