Skip to content
CryoCryo home
Stdlibnet::http2

codec

import std::net::http2::codec; · source

Header-block coding for an HTTP/2 connection. A connection turns each request's or response's header list into a header block and back through a HeaderCodec. HpackCodec, RFC 7541's HPACK, is the one every connection uses unless it is built with another: Http2Connection<S> is Http2Connection<S, HpackCodec>, and Http2Connection<S, MyCodec> codes its header blocks with MyCodec. Both ends of a connection must code the same way, so a codec other than HPACK is for a peer that speaks it.

Types

HeaderField

type struct HeaderField {
    name:  String;
    value: String;
}

One header field, owning its name and value bytes. new copies both as given — no case folding and no validation.

Properties

PropertyType
nameString
valueString

Constructors

static new(name: Str, value: Str) -> HeaderField;

A field holding copies of name and value, both as given: no case folding and no validation.

HeaderCodec

type trait HeaderCodec {
    encode_field(mut &this, out: mut &Array<u8>, name: Str, value: Str, sensitive: boolean) -> void;
    decode(mut &this, block: &Slice<u8>) -> Option<Array<HeaderField>>;
    limit_encoder_table(mut &this, size: i64) -> void;
}

How a connection writes and reads header blocks. A codec may keep state across the blocks of one connection, as HPACK's tables do; it sees every block of one direction in order. A sensitive field passed to encode_field carries a credential: a codec that remembers fields for later blocks must not remember this one, and must tell whatever relays the block not to either. decode returns None for a block that is malformed or decodes past what the codec accepts. limit_encoder_table passes on the peer's SETTINGS_HEADER_TABLE_SIZE; a codec that stores nothing ignores it.

Methods

encode_field(mut &this, out: mut &Array<u8>, name: Str, value: Str, sensitive: boolean) -> void;

Append the encoding of the field name: value to out. A sensitive field carries a credential: a codec that remembers fields for later blocks must not remember this one, and must tell whatever relays the block not to either.

decode(mut &this, block: &Slice<u8>) -> Option<Array<HeaderField>>;

The fields block encodes, in order, or none when it is malformed or decodes past what the codec accepts.

limit_encoder_table(mut &this, size: i64) -> void;

The most the peer's decoder stores, as its SETTINGS_HEADER_TABLE_SIZE says. A codec that stores nothing ignores it.

Implementors

implement trait HeaderCodec for struct HpackCodec

HpackCodec

type struct HpackCodec {
    private encoder: HpackEncoder;
    private decoder: HpackDecoder;
}

HPACK: an encoder and a decoder, each with its own dynamic table. new(table_size) bounds the decoder's table at table_size octets, as the connection advertises it, and starts the encoder at the same size until the peer's SETTINGS says otherwise. The HPACK and Huffman coders behind it are internal to the standard library.

Constructors

static new(table_size: i64) -> HpackCodec;

A codec whose own decoder table holds at most table_size octets, as the connection advertises it, and whose encoder starts at the same size until the peer's SETTINGS says otherwise.

Trait implementations

implement trait HeaderCodec for struct HpackCodec