Expand description
H2 frame parser (nom-based).
Decodes every RFC 9113 §6 frame type plus RFC 9218 PRIORITY_UPDATE and
unknown extension frames; rejects malformed framing with the matching
H2Error so the connection can react with GOAWAY / RST_STREAM. Mostly
zero-allocation, with bounded Vec<u8> allocations on priority_update
and a SETTINGS-list cap (cf. priority_update_frame and the SETTINGS
allocation cap test). Frame-size invariants are enforced via
ensure_frame_size!.
Structs§
- Continuation
- Continuation frames are handled inline during HEADERS parsing. The
wire-level parser does not track connection state (whether the previous
frame was HEADERS/PUSH_PROMISE with END_HEADERS=0), so standalone
CONTINUATION is rejected at the h2 state-machine layer
(
handle_header_state): when a CONTINUATION frame header is observed while the state isH2State::Header(i.e. no header block is in progress) we emit GOAWAY(PROTOCOL_ERROR) per RFC 9113 §6.10. - Data
- Frame
Header - GoAway
- Headers
- Parser
Error - Ping
- Priority
- Priority
Update - RFC 9218 §7.1 PRIORITY_UPDATE frame payload.
- Push
Promise - PushPromise is always rejected with PROTOCOL_ERROR at the wire layer.
Sozu never announces
SETTINGS_ENABLE_PUSH=1, and RFC 9113 §8.4 requires that a peer which has not enabled server push treat a received PUSH_PROMISE as a connection error of type PROTOCOL_ERROR. Rejecting in the parser is defence-in-depth: any future refactor ofmux/h2.rsthat forgets to callhandle_push_promise_framecannot silently accept push traffic. The struct is retained so the outer match inh2.rsstill compiles, butpush_promise_framenever constructs it. - RstStream
- Setting
- Settings
- Stream
Dependency - Window
Update
Enums§
Constants§
- FLAG_
ACK - ACK flag on SETTINGS/PING (§6.5, §6.7)
- FLAG_
END_ HEADERS - END_HEADERS flag — signals last header block fragment (§6.2, §6.10)
- FLAG_
END_ STREAM - END_STREAM flag — signals last frame for this stream (§6.1, §6.2)
- FLAG_
PADDED - PADDED flag — indicates padding is present (§6.1, §6.2)
- FLAG_
PRIORITY - PRIORITY flag on HEADERS — stream dependency follows (§6.2)
- FRAME_
HEADER_ SIZE - H2 frame header size in bytes (RFC 9113 §4.1)
- GOAWAY_
PAYLOAD_ SIZE - MAX_
SETTINGS_ ENTRIES - Maximum SETTINGS entries accepted in a single SETTINGS frame.
- PING_
PAYLOAD_ SIZE - PRIORITY_
PAYLOAD_ SIZE - PRIORITY_
UPDATE_ MAX_ VALUE - Maximum length of the
priority_field_valueportion of a PRIORITY_UPDATE frame (RFC 9218 §7.1). The field is a Structured Field Item (RFC 8941): ASCII-only, intended for compact dictionary payloads such asu=3, i. 1024 bytes mirrors nghttp2’sNGHTTP2_MAX_PRIORITY_VALUE_LENand the upper-bound theh2Rust crate enforces, an order of magnitude tighter thanSETTINGS_MAX_FRAME_SIZE— the attacker is denied a per-frame 16 KiB allocation primitive sized in single TCP segments. - PRIORITY_
UPDATE_ MIN_ PAYLOAD - Minimum payload size for a PRIORITY_UPDATE frame (RFC 9218 §7.1): the 4-byte prioritized stream ID. The priority field value is allowed to be empty (defaults to the RFC 9218 §4 defaults).
- RST_
STREAM_ PAYLOAD_ SIZE - SETTINGS_
COUNT - Number of settings entries we send in our SETTINGS frame
- SETTINGS_
ENABLE_ CONNECT_ PROTOCOL - SETTINGS_
ENABLE_ PUSH - SETTINGS_
ENTRY_ SIZE - SETTINGS_
HEADER_ TABLE_ SIZE - SETTINGS_
INITIAL_ WINDOW_ SIZE - SETTINGS_
MAX_ CONCURRENT_ STREAMS - SETTINGS_
MAX_ FRAME_ SIZE - SETTINGS_
MAX_ HEADER_ LIST_ SIZE - SETTINGS_
NO_ RFC7540_ PRIORITIES - STREAM_
ID_ MASK - Mask to extract 31-bit stream ID, clearing the reserved MSB (RFC 9113 §4.1)
- WINDOW_
UPDATE_ PAYLOAD_ SIZE
Functions§
- continuation_
frame - data_
frame - frame_
body - frame_
header - goaway_
frame - headers_
frame - ping_
frame - preface
- priority_
frame - priority_
update_ frame - RFC 9218 §7.1 PRIORITY_UPDATE frame parser. Payload layout:
- push_
promise_ frame - rst_
stream_ frame - settings_
frame - unknown_
frame - Silently consume the payload of a frame whose type byte is not recognised,
per RFC 9113 §5.5 (“Implementations MUST ignore and discard frames of
unknown type”). Previously covered RFC 9218 PRIORITY_UPDATE (type 0x10);
PRIORITY_UPDATE is now parsed through
priority_update_frame. - window_
update_ frame