Skip to content

Commit 6c9182c

Browse files
authored
feat(http2): Add 'header_table_size()' method to server builder (#4062)
1 parent e9be344 commit 6c9182c

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ atomic-waker = { version = "1.1.2", optional = true }
3131
futures-channel = { version = "0.3", optional = true }
3232
futures-core = { version = "0.3.31", optional = true }
3333
futures-util = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
34-
h2 = { version = "0.4.6", optional = true }
34+
h2 = { version = "0.4.14", optional = true }
3535
http-body-util = { version = "0.1", optional = true }
3636
httparse = { version = "1.9", optional = true }
3737
httpdate = { version = "1.0", optional = true }

src/proto/h2/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub(crate) struct Config {
5353
pub(crate) keep_alive_interval: Option<Duration>,
5454
pub(crate) keep_alive_timeout: Duration,
5555
pub(crate) max_send_buffer_size: usize,
56+
pub(crate) header_table_size: Option<u32>,
5657
pub(crate) max_header_list_size: u32,
5758
pub(crate) date_header: bool,
5859
}
@@ -68,6 +69,7 @@ impl Default for Config {
6869
max_concurrent_streams: Some(200),
6970
max_pending_accept_reset_streams: None,
7071
max_local_error_reset_streams: Some(DEFAULT_MAX_LOCAL_ERROR_RESET_STREAMS),
72+
header_table_size: None,
7173
keep_alive_interval: None,
7274
keep_alive_timeout: Duration::from_secs(20),
7375
max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE,
@@ -142,6 +144,9 @@ where
142144
if let Some(max) = config.max_pending_accept_reset_streams {
143145
builder.max_pending_accept_reset_streams(max);
144146
}
147+
if let Some(size) = config.header_table_size {
148+
builder.header_table_size(size);
149+
}
145150
if config.enable_connect_protocol {
146151
builder.enable_connect_protocol();
147152
}

src/server/conn/http2.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ impl<E> Builder<E> {
260260
self
261261
}
262262

263+
/// Sets the header table size.
264+
///
265+
/// This setting informs the peer of the maximum size of the header compression
266+
/// table used to encode header blocks, in octets. The encoder may select any value
267+
/// equal to or less than the header table size specified by the sender.
268+
///
269+
/// The default value of crate `h2` is 4,096.
270+
pub fn header_table_size(&mut self, size: impl Into<Option<u32>>) -> &mut Self {
271+
self.h2_builder.header_table_size = size.into();
272+
self
273+
}
274+
263275
/// Sets the max size of received header frames.
264276
///
265277
/// Default is currently 16KB, but can change.

0 commit comments

Comments
 (0)