Skip to content

Commit

Permalink
feat(http2): add max_pending_accept_reset_streams(num) back to HTTP…
Browse files Browse the repository at this point in the history
…/2 server builder (#3507)

In places where required, the `max_pending_accept_reset_streams` option was reimplemented, as in PR #3201

cc #3461
  • Loading branch information
dsgallups authored Dec 29, 2023
1 parent 9b5f409 commit a9fa893
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/proto/h2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub(crate) struct Config {
pub(crate) max_frame_size: u32,
pub(crate) enable_connect_protocol: bool,
pub(crate) max_concurrent_streams: Option<u32>,
pub(crate) max_pending_accept_reset_streams: Option<usize>,
pub(crate) keep_alive_interval: Option<Duration>,
pub(crate) keep_alive_timeout: Duration,
pub(crate) max_send_buffer_size: usize,
Expand All @@ -64,6 +65,7 @@ impl Default for Config {
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
enable_connect_protocol: false,
max_concurrent_streams: Some(200),
max_pending_accept_reset_streams: None,
keep_alive_interval: None,
keep_alive_timeout: Duration::from_secs(20),
max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE,
Expand Down Expand Up @@ -131,6 +133,9 @@ where
if let Some(max) = config.max_concurrent_streams {
builder.max_concurrent_streams(max);
}
if let Some(max) = config.max_pending_accept_reset_streams {
builder.max_pending_accept_reset_streams(max);
}
if config.enable_connect_protocol {
builder.enable_connect_protocol();
}
Expand Down
11 changes: 11 additions & 0 deletions src/server/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ impl<E> Builder<E> {
}
}

/// 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
}

/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
/// stream-level flow control.
///
Expand Down

0 comments on commit a9fa893

Please sign in to comment.