Trailers Module

Functions and values

Function or value Description

RequestUserStateKey

Full Usage: RequestUserStateKey

Returns: string

userState key under which trailers received on a request are surfaced once the dispatch loop has reassembled the trailing HEADERS block.

Returns: string

UserStateKey

Full Usage: UserStateKey

Returns: string

userState key under which response trailers are stored on the HttpContext. Public so that callers driving HttpResult directly (the HTTP/2 writer in particular) can locate the recorded trailers without adding a struct field to HttpResult.

Returns: string

get ctx

Full Usage: get ctx

Parameters:
Returns: (string * string) list

Get the response trailers previously recorded on the context, or an empty list if no trailers have been set. Order is preserved in the order they were added.

ctx : HttpContext
Returns: (string * string) list

getRequest ctx

Full Usage: getRequest ctx

Parameters:
Returns: (string * string) list

Get the request trailers (trailing HEADERS received after the DATA stream), or an empty list if no trailers were received. Populated by the HTTP/2 dispatch loop.

ctx : HttpContext
Returns: (string * string) list

set name value ctx

Full Usage: set name value ctx

Parameters:
Returns: Async<HttpContext option>

Set (or replace) a single response trailer. Analogous to `Writers.setHeader`: a later call with the same name (case-insensitive) supersedes the earlier one. Under HTTP/1.x this is a no-op semantically — the trailer list is recorded but never emitted.

name : string
value : string
ctx : HttpContext
Returns: Async<HttpContext option>

setMany trailers ctx

Full Usage: setMany trailers ctx

Parameters:
Returns: Async<HttpContext option>

Set the entire response trailers list, replacing anything previously recorded. The list is not validated here; the HTTP/2 writer will run `validate` before emitting and treat a failure as a stream-level PROTOCOL_ERROR.

trailers : (string * string) list
ctx : HttpContext
Returns: Async<HttpContext option>

validate fields

Full Usage: validate fields

Parameters:
    fields : (string * string) list

Returns: Result<unit, ErrorCode>

Validate a list of trailer fields. Returns the first violation encountered, or `Ok ()` if all fields are permitted as trailers.

fields : (string * string) list
Returns: Result<unit, ErrorCode>

validateField (name, value)

Full Usage: validateField (name, value)

Parameters:
    name : string
    value : string

Returns: Result<unit, ErrorCode>

Validate a single trailer field. Returns `Ok ()` if the field is permitted as a trailer per RFC 7540 §8.1, or `Result.Error ProtocolError` otherwise. The malformed-trailer-block disposition is a stream-level PROTOCOL_ERROR (RFC 7540 §8.1.2 / §8.1.2.6).

name : string
value : string
Returns: Result<unit, ErrorCode>