Module H2_hpack.Encoder

Encoder

HPACK encoder with dynamic table context.

type t

Encoder context maintaining dynamic table state.

val create : int -> t

create capacity creates an encoder with the given dynamic table capacity in bytes (default 4096).

val set_capacity : t -> int -> unit

set_capacity t capacity updates the dynamic table capacity. This may evict entries if the new capacity is smaller.

val encode_headers : t -> Cstruct.t -> header list -> int

encode_headers t buf headers encodes headers into buf. Returns the number of bytes written.

The buffer must be large enough for the encoded output. A safe estimate is 16KB for typical header blocks.

Per RFC 7541, encoding updates the dynamic table state, so the same encoder must be used for all header blocks on a connection.