Skip to content

Commit

Permalink
feat(client): add max_pending_accept_reset_streams HTTP2 option (#3617
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dswij authored Apr 1, 2024
1 parent 6ecf852 commit 330ddf1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,17 @@ where
self
}

/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
///
/// This will default to the default value set by the [`h2` crate](https://crates.io/crates/h2).
/// As of v0.4.0, it is 20.
///
/// See <https://github.com/hyperium/hyper/issues/2877> for more information.
pub fn max_pending_accept_reset_streams(&mut self, max: impl Into<Option<usize>>) -> &mut Self {
self.h2_builder.max_pending_accept_reset_streams = max.into();
self
}

/// Constructs a connection with the configured options and IO.
/// See [`client::conn`](crate::client::conn) for more.
///
Expand Down
5 changes: 5 additions & 0 deletions src/proto/h2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub(crate) struct Config {
pub(crate) keep_alive_while_idle: bool,
pub(crate) max_concurrent_reset_streams: Option<usize>,
pub(crate) max_send_buffer_size: usize,
pub(crate) max_pending_accept_reset_streams: Option<usize>,
}

impl Default for Config {
Expand All @@ -88,6 +89,7 @@ impl Default for Config {
keep_alive_while_idle: false,
max_concurrent_reset_streams: None,
max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE,
max_pending_accept_reset_streams: None,
}
}
}
Expand All @@ -104,6 +106,9 @@ fn new_builder(config: &Config) -> Builder {
if let Some(max) = config.max_concurrent_reset_streams {
builder.max_concurrent_reset_streams(max);
}
if let Some(max) = config.max_pending_accept_reset_streams {
builder.max_pending_accept_reset_streams(max);
}
builder
}

Expand Down

0 comments on commit 330ddf1

Please sign in to comment.