Skip to content

Commit

Permalink
feat: Add http2_max_header_list_size to the client builder (seanmon…
Browse files Browse the repository at this point in the history
  • Loading branch information
DSharifi authored and Nutomic committed Nov 7, 2024
1 parent 25e4cff commit cc33fb2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ encoding_rs = { version = "0.8", optional = true }
http-body = "1"
http-body-util = "0.1"
hyper = { version = "1.1", features = ["http1", "client"] }
hyper-util = { version = "0.1.3", features = ["http1", "client", "client-legacy", "tokio"] }
hyper-util = { version = "0.1.10", features = ["http1", "client", "client-legacy", "tokio"] }
h2 = { version = "0.4", optional = true }
once_cell = "1.18"
log = "0.4.17"
Expand Down Expand Up @@ -173,7 +173,7 @@ futures-channel = { version = "0.3", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
env_logger = "0.10"
hyper = { version = "1.1.0", default-features = false, features = ["http1", "http2", "client", "server"] }
hyper-util = { version = "0.1.3", features = ["http1", "http2", "client", "client-legacy", "server-auto", "tokio"] }
hyper-util = { version = "0.1.10", features = ["http1", "http2", "client", "client-legacy", "server-auto", "tokio"] }
serde = { version = "1.0", features = ["derive"] }
libflate = "2.1"
brotli_crate = { package = "brotli", version = "6.0.0" }
Expand Down
17 changes: 17 additions & 0 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ struct Config {
#[cfg(feature = "http2")]
http2_max_frame_size: Option<u32>,
#[cfg(feature = "http2")]
http2_max_header_list_size: Option<u32>,
#[cfg(feature = "http2")]
http2_keep_alive_interval: Option<Duration>,
#[cfg(feature = "http2")]
http2_keep_alive_timeout: Option<Duration>,
Expand Down Expand Up @@ -247,6 +249,8 @@ impl ClientBuilder {
#[cfg(feature = "http2")]
http2_max_frame_size: None,
#[cfg(feature = "http2")]
http2_max_header_list_size: None,
#[cfg(feature = "http2")]
http2_keep_alive_interval: None,
#[cfg(feature = "http2")]
http2_keep_alive_timeout: None,
Expand Down Expand Up @@ -743,6 +747,9 @@ impl ClientBuilder {
if let Some(http2_max_frame_size) = config.http2_max_frame_size {
builder.http2_max_frame_size(http2_max_frame_size);
}
if let Some(http2_max_header_list_size) = config.http2_max_header_list_size {
builder.http2_max_header_list_size(http2_max_header_list_size);
}
if let Some(http2_keep_alive_interval) = config.http2_keep_alive_interval {
builder.http2_keep_alive_interval(http2_keep_alive_interval);
}
Expand Down Expand Up @@ -1318,6 +1325,16 @@ impl ClientBuilder {
self
}

/// Sets the maximum size of received header frames for HTTP2.
///
/// Default is currently 16KB, but can change.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn http2_max_header_list_size(mut self, max_header_size_bytes: u32) -> ClientBuilder {
self.config.http2_max_header_list_size = Some(max_header_size_bytes);
self
}

/// Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive.
///
/// Pass `None` to disable HTTP2 keep-alive.
Expand Down
9 changes: 9 additions & 0 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,15 @@ impl ClientBuilder {
self.with_inner(|inner| inner.http2_max_frame_size(sz))
}

/// Sets the maximum size of received header frames for HTTP2.
///
/// Default is currently 16KB, but can change.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn http2_max_header_list_size(self, max_header_size_bytes: u32) -> ClientBuilder {
self.with_inner(|inner| inner.http2_max_header_list_size(max_header_size_bytes))
}

/// This requires the optional `http3` feature to be
/// enabled.
#[cfg(feature = "http3")]
Expand Down

0 comments on commit cc33fb2

Please sign in to comment.