Push Module

Types

Type Description

PushPromise

A push intent recorded by a WebPart, consumed by the HTTP/2 writer (when wired) to emit a PUSH_PROMISE + the synthesised request exchange. `path` is the request-target (e.g. "/style.css"); `headers` is the additional request header block (`:method`, `:scheme`, `:authority` are filled in by the writer from the parent request).

Functions and values

Function or value Description

UserStateKey

Full Usage: UserStateKey

Returns: string

userState key under which the list of recorded push promises lives on HttpContext. Stored as `PushPromise list` boxed once.

Returns: string

canPush peerSettings

Full Usage: canPush peerSettings

Parameters:
Returns: bool

Honour the peer's SETTINGS_ENABLE_PUSH value. RFC 7540 §6.5.2: "Initial value: 1, which indicates that server push is permitted." If the client has never sent SETTINGS, callers should use `defaultSetting` whose `enablePush = true`.

peerSettings : Settings
Returns: bool

get ctx

Full Usage: get ctx

Parameters:
Returns: PushPromise list

Return the push promises recorded on the context, in the order they were added. Empty if none. Tolerates a null `userState` (e.g. on a synthetic `HttpContext.empty`).

ctx : HttpContext
Returns: PushPromise list

nextPromisedStreamId counter

Full Usage: nextPromisedStreamId counter

Parameters:
    counter : int32 ref

Returns: int32 option

Allocate the next promised stream id from a server-side counter. RFC 7540 §5.1.1: streams initiated by the server use even-numbered identifiers and the value 0x0 is reserved. Mutates the counter; the next call returns the next even id. Returns `None` if the counter would overflow the legal 31-bit space, in which case the caller MUST send a GOAWAY and stop creating streams.

counter : int32 ref
Returns: int32 option

push path headers ctx

Full Usage: push path headers ctx

Parameters:
    path : string
    headers : (string * string) list
    ctx : HttpContext

Returns: Async<HttpContext option>

Public WebPart: record a push intent for `path` with the given request header fragment. No-op under HTTP/1.x — the recorded list is consumed only by the HTTP/2 writer. Multiple calls append; identical paths are not deduplicated (a server may legitimately push the same path twice with different headers, and dedup is the writer's policy).

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

withinMaxConcurrentStreams currentActive maxConcurrent

Full Usage: withinMaxConcurrentStreams currentActive maxConcurrent

Parameters:
    currentActive : int
    maxConcurrent : int32 option

Returns: bool

Check whether starting another stream would respect the peer's SETTINGS_MAX_CONCURRENT_STREAMS. `currentActive` is the number of streams the server currently has Open or HalfClosed (per RFC 7540 §5.1.2 the limit counts those states). When the peer has not advertised a limit (`None`), pushing is permitted.

currentActive : int
maxConcurrent : int32 option
Returns: bool