Skip to main content

http2_proto/frame/
mod.rs

1//! HTTP/2 frame types and parsing.
2//!
3//! HTTP/2 frames have a common 9-byte header:
4//! ```text
5//! +-----------------------------------------------+
6//! |                 Length (24)                   |
7//! +---------------+---------------+---------------+
8//! |   Type (8)    |   Flags (8)   |
9//! +-+-------------+---------------+-------------------------------+
10//! |R|                 Stream Identifier (31)                      |
11//! +=+=============================================================+
12//! |                   Frame Payload (0...)                      ...
13//! +---------------------------------------------------------------+
14//! ```
15
16mod decode;
17mod encode;
18mod error;
19mod types;
20
21pub use decode::FrameDecoder;
22pub use encode::FrameEncoder;
23pub use error::{ErrorCode, FrameError};
24pub use types::*;
25
26/// Maximum frame size allowed by HTTP/2 spec (2^24 - 1).
27pub const MAX_FRAME_SIZE: u32 = 16_777_215;
28
29/// Default maximum frame size (16 KB).
30pub const DEFAULT_MAX_FRAME_SIZE: u32 = 16_384;
31
32/// Frame header size in bytes.
33pub const FRAME_HEADER_SIZE: usize = 9;
34
35/// Connection preface sent by clients.
36pub const CONNECTION_PREFACE: &[u8] = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
37
38/// Default initial window size for flow control.
39pub const DEFAULT_INITIAL_WINDOW_SIZE: u32 = 65_535;
40
41/// Default header table size for HPACK.
42pub const DEFAULT_HEADER_TABLE_SIZE: u32 = 4_096;
43
44/// Maximum concurrent streams default.
45pub const DEFAULT_MAX_CONCURRENT_STREAMS: u32 = 100;