Skip to content

Commit 1c5b1b8

Browse files
committed
feat(client): add max_header_list_size(num) to http2::Builder.
1 parent df33d4d commit 1c5b1b8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/client/conn/http2.rs

+8
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ where
342342
self
343343
}
344344

345+
/// Sets the max size of received header frames.
346+
///
347+
/// Default is currently 16MB, but can change.
348+
pub fn max_header_list_size(&mut self, max: u32) -> &mut Self {
349+
self.h2_builder.max_header_list_size = max;
350+
self
351+
}
352+
345353
/// Sets an interval for HTTP2 Ping frames should be sent to keep a
346354
/// connection alive.
347355
///

src/proto/h2/client.rs

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb
5151
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb
5252
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
5353
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 1024; // 1mb
54+
const DEFAULT_MAX_HEADER_LIST_SIZE: u32 = 16 << 20; // 16mb
5455

5556
// The maximum number of concurrent streams that the client is allowed to open
5657
// before it receives the initial SETTINGS frame from the server.
@@ -68,6 +69,7 @@ pub(crate) struct Config {
6869
pub(crate) initial_stream_window_size: u32,
6970
pub(crate) initial_max_send_streams: usize,
7071
pub(crate) max_frame_size: u32,
72+
pub(crate) max_header_list_size: u32,
7173
pub(crate) keep_alive_interval: Option<Duration>,
7274
pub(crate) keep_alive_timeout: Duration,
7375
pub(crate) keep_alive_while_idle: bool,
@@ -84,6 +86,7 @@ impl Default for Config {
8486
initial_stream_window_size: DEFAULT_STREAM_WINDOW,
8587
initial_max_send_streams: DEFAULT_INITIAL_MAX_SEND_STREAMS,
8688
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
89+
max_header_list_size: DEFAULT_MAX_HEADER_LIST_SIZE,
8790
keep_alive_interval: None,
8891
keep_alive_timeout: Duration::from_secs(20),
8992
keep_alive_while_idle: false,
@@ -101,6 +104,7 @@ fn new_builder(config: &Config) -> Builder {
101104
.initial_window_size(config.initial_stream_window_size)
102105
.initial_connection_window_size(config.initial_conn_window_size)
103106
.max_frame_size(config.max_frame_size)
107+
.max_header_list_size(config.max_header_list_size)
104108
.max_send_buffer_size(config.max_send_buffer_size)
105109
.enable_push(false);
106110
if let Some(max) = config.max_concurrent_reset_streams {

0 commit comments

Comments
 (0)