use std::time::Duration;
#[derive(Debug, Clone)]
pub struct PriorityTree {
pub priorities: Vec<(u32, u32, u8, bool)>,
}
impl PriorityTree {
pub fn chrome() -> Self {
Self {
priorities: vec![
(3, 0, 201, false), (5, 0, 101, false), (7, 0, 1, false), (9, 7, 1, false), (11, 3, 1, false), ],
}
}
pub fn firefox() -> Self {
Self {
priorities: vec![(3, 0, 201, false), (5, 0, 101, false), (7, 0, 1, false)],
}
}
pub fn none() -> Self {
Self {
priorities: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct Http2Settings {
pub header_table_size: u32,
pub enable_push: bool,
pub max_concurrent_streams: u32,
pub initial_window_size: u32,
pub max_frame_size: u32,
pub max_header_list_size: u32,
pub initial_window_update: u32,
pub send_all_settings: bool,
pub priority_tree: Option<PriorityTree>,
pub ping_interval: Option<Duration>,
pub handshake_timeout: Option<Duration>,
}
impl Default for Http2Settings {
fn default() -> Self {
Self {
header_table_size: 65536,
enable_push: false,
max_concurrent_streams: 1000,
initial_window_size: 6291456,
max_frame_size: 16384,
max_header_list_size: 262144,
initial_window_update: 15663105, send_all_settings: true, priority_tree: Some(PriorityTree::chrome()), ping_interval: Some(Duration::from_secs(45)), handshake_timeout: Some(Duration::from_secs(10)),
}
}
}
impl Http2Settings {
pub fn firefox() -> Self {
Self {
header_table_size: 65536,
enable_push: true, max_concurrent_streams: 100, initial_window_size: 131072, max_frame_size: 16384,
max_header_list_size: 0, initial_window_update: 12517377, send_all_settings: false, priority_tree: Some(PriorityTree::firefox()), ping_interval: Some(Duration::from_secs(30)), handshake_timeout: Some(Duration::from_secs(10)),
}
}
}