Skip to content
CryoCryo home
Stdlibnet::http2

settings

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

HTTP/2 SETTINGS parameters, RFC 7540 section 6.5. A SETTINGS frame payload is a sequence of 6-octet entries: a 16-bit identifier followed by a 32-bit value.

Types

Settings

type struct Settings {
    header_table_size:      u32;
    enable_push:            u32;
    max_concurrent_streams: u32;
    initial_window_size:    u32;
    max_frame_size:         u32;
    max_header_list_size:   u32;
}

The six parameters of one side of a connection, one field per identifier. The type is internal to the library: Http2Connection keeps one for each side and applies what the peer sends, and this section says what that does. It starts from defaults() — the protocol defaults, with the u32 maximum standing for "unlimited" — and fold a received payload in with apply_payload; unknown identifiers are ignored, as the protocol requires.

A value the protocol forbids is refused with the error code the connection must end with, and stores nothing: PROTOCOL_ERROR for SETTINGS_ENABLE_PUSH other than 0 or 1 and for SETTINGS_MAX_FRAME_SIZE outside MIN_MAX_FRAME_SIZE to MAX_MAX_FRAME_SIZE, and FLOW_CONTROL_ERROR for SETTINGS_INITIAL_WINDOW_SIZE above MAX_WINDOW_SIZE. apply_payload refuses a length that is not a multiple of 6 with FRAME_SIZE_ERROR; at the first value it refuses, the entries before it stay applied.

Properties

PropertyType
header_table_sizeu32
enable_pushu32
max_concurrent_streamsu32
initial_window_sizeu32
max_frame_sizeu32
max_header_list_sizeu32

Constructors

static defaults() -> Settings;

Protocol defaults (RFC 7540 section 6.5.2). "Unlimited" parameters use the u32 maximum as a sentinel.

Methods

apply_one(mut &this, id: u16, value: u32) -> Result<(), u32>;

Apply a single parsed (identifier, value). Unknown identifiers are ignored. A value the protocol forbids is refused with the error code the connection must end with, and stores nothing: PROTOCOL_ERROR for SETTINGS_ENABLE_PUSH other than 0 or 1 and for SETTINGS_MAX_FRAME_SIZE outside 16384 to 16777215, and FLOW_CONTROL_ERROR for SETTINGS_INITIAL_WINDOW_SIZE above 2^31 - 1.

apply_payload(mut &this, payload: &Slice<u8>) -> Result<(), u32>;

Parse a SETTINGS frame payload, applying its entries in order. Refused with FRAME_SIZE_ERROR when the length is not a multiple of 6, and with apply_one's code at the first value it refuses; the entries before that one stay applied.

Free Functions

function push_entry(out: mut &Array<u8>, id: u16, value: u32) -> void;

Append a (identifier, value) entry to a SETTINGS payload buffer.

A payload to send is built one entry at a time, then queued as a FRAME_SETTINGS frame.

Constants

const SETTINGS_HEADER_TABLE_SIZE:      u16 = 0x1;
const SETTINGS_ENABLE_PUSH:            u16 = 0x2;
const SETTINGS_MAX_CONCURRENT_STREAMS: u16 = 0x3;
const SETTINGS_INITIAL_WINDOW_SIZE:    u16 = 0x4;
const SETTINGS_MAX_FRAME_SIZE:         u16 = 0x5;
const SETTINGS_MAX_HEADER_LIST_SIZE:   u16 = 0x6;
const MAX_WINDOW_SIZE:                 u32 = 2147483647;
const MIN_MAX_FRAME_SIZE:              u32 = 16384;
const MAX_MAX_FRAME_SIZE:              u32 = 16777215;