Frames

The frames layer implements the HTTP/2 wire format per RFC 9113: encoding and decoding the 9-byte frame header, the 10 frame types (DATA, HEADERS, PRIORITY, RSTSTREAM, SETTINGS, PUSHPROMISE, PING, GOAWAY, WINDOW_UPDATE, CONTINUATION), and a small set of per-frame-type parser/constructor helpers. All of these are pure Base-Julia operations on Vector{UInt8} — no C library dependency.

Wire format constants

Namespace submodules

RFC 9113's frame types, flags, settings parameters, and error codes are each exposed as a submodule so callers can write PureHTTP2.FrameType.DATA, PureHTTP2.FrameFlags.END_STREAM, etc.

PureHTTP2.FrameTypeModule
FrameType

HTTP/2 frame types per RFC 7540 Section 6.

Frame Types

  • DATA (0x0): Conveys payload data
  • HEADERS (0x1): Opens a stream and carries header block
  • PRIORITY (0x2): Specifies stream priority
  • RST_STREAM (0x3): Terminates a stream
  • SETTINGS (0x4): Configuration parameters
  • PUSH_PROMISE (0x5): Server push notification
  • PING (0x6): Connectivity check and RTT measurement
  • GOAWAY (0x7): Connection shutdown notification
  • WINDOW_UPDATE (0x8): Flow control window adjustment
  • CONTINUATION (0x9): Header block continuation
source
PureHTTP2.FrameFlagsModule
FrameFlags

HTTP/2 frame flags per RFC 7540.

Common Flags

  • END_STREAM (0x1): Last frame for stream (DATA, HEADERS)
  • END_HEADERS (0x4): End of header block (HEADERS, PUSH_PROMISE, CONTINUATION)
  • PADDED (0x8): Frame is padded (DATA, HEADERS, PUSH_PROMISE)
  • PRIORITY (0x20): Stream dependency info present (HEADERS)
  • ACK (0x1): Settings/Ping acknowledgment (SETTINGS, PING)
source
PureHTTP2.ErrorCodeModule
ErrorCode

HTTP/2 error codes per RFC 7540 Section 7.

Error Codes

  • NO_ERROR (0x0): No error
  • PROTOCOL_ERROR (0x1): Protocol error detected
  • INTERNAL_ERROR (0x2): Internal error
  • FLOW_CONTROL_ERROR (0x3): Flow control violation
  • SETTINGS_TIMEOUT (0x4): Settings not acknowledged
  • STREAM_CLOSED (0x5): Frame received for closed stream
  • FRAME_SIZE_ERROR (0x6): Invalid frame size
  • REFUSED_STREAM (0x7): Stream refused
  • CANCEL (0x8): Stream cancelled
  • COMPRESSION_ERROR (0x9): HPACK error
  • CONNECT_ERROR (0xa): Connection error
  • ENHANCE_YOUR_CALM (0xb): Excessive load
  • INADEQUATE_SECURITY (0xc): Underlying transport inadequate
  • HTTP_1_1_REQUIRED (0xd): Use HTTP/1.1
source
PureHTTP2.SettingsParameterModule
SettingsParameter

HTTP/2 SETTINGS parameters per RFC 7540 Section 6.5.2.

Parameters

  • HEADER_TABLE_SIZE (0x1): HPACK dynamic table size (default: 4096)
  • ENABLE_PUSH (0x2): Server push enabled (default: 1)
  • MAX_CONCURRENT_STREAMS (0x3): Maximum concurrent streams (default: unlimited)
  • INITIAL_WINDOW_SIZE (0x4): Initial flow control window (default: 65535)
  • MAX_FRAME_SIZE (0x5): Maximum frame payload size (default: 16384)
  • MAX_HEADER_LIST_SIZE (0x6): Maximum header list size (default: unlimited)
source

Frame header

PureHTTP2.FrameHeaderType
FrameHeader

HTTP/2 frame header (9 bytes).

Fields

  • length::UInt32: Payload length (24 bits)
  • frame_type::UInt8: Frame type
  • flags::UInt8: Frame-specific flags
  • stream_id::UInt32: Stream identifier (31 bits)
source
PureHTTP2.has_flagFunction
has_flag(header::FrameHeader, flag::UInt8) -> Bool

Check if a frame header has a specific flag set.

source

Generic frame

PureHTTP2.FrameType
Frame

HTTP/2 frame consisting of header and payload.

Fields

  • header::FrameHeader: Frame header
  • payload::Vector{UInt8}: Frame payload
source
PureHTTP2.decode_frameFunction
decode_frame(bytes::AbstractVector{UInt8}) -> Tuple{Frame, Int}

Decode a complete frame from bytes. Returns the frame and the number of bytes consumed.

source

Per-type constructors and parsers

These helpers build or parse specific frame types while enforcing the type's invariants (e.g., ping_frame rejects non-8-byte payloads).

PureHTTP2.headers_frameFunction
headers_frame(stream_id, header_block; end_stream=false, end_headers=true) -> Frame

Create a HEADERS frame.

source
PureHTTP2.settings_frameFunction
settings_frame(settings; ack=false) -> Frame

Create a SETTINGS frame.

Arguments

  • settings::Vector{Tuple{UInt16, UInt32}}: List of (parameter, value) pairs
  • ack::Bool: Whether this is a SETTINGS acknowledgment
source
PureHTTP2.ping_frameFunction
ping_frame(opaque_data; ack=false) -> Frame

Create a PING frame.

Arguments

  • opaque_data::Vector{UInt8}: 8 bytes of opaque data
  • ack::Bool: Whether this is a PING acknowledgment
source
PureHTTP2.parse_goaway_frameFunction
parse_goaway_frame(frame::Frame) -> Tuple{UInt32, UInt32, Vector{UInt8}}

Parse a GOAWAY frame. Returns (laststreamid, errorcode, debugdata).

source
PureHTTP2.window_update_frameFunction
window_update_frame(stream_id, increment) -> Frame

Create a WINDOW_UPDATE frame.

Arguments

  • stream_id::Integer: Stream ID (0 for connection-level)
  • increment::Integer: Window size increment (1 to 2^31-1)
source