From b33dbd21e5ab58bc57659490783478d753e9830c Mon Sep 17 00:00:00 2001 From: Allan Zhang Date: Wed, 3 Jan 2024 01:26:13 -0500 Subject: [PATCH] Add `max_pending_accept_reset_streams` This function was in 0.14 but missed in 1.0. The original function was merged [here](https://github.com/hyperium/hyper/pull/3201/files/e8296d1c5bded88a508f1ca1f35791c30803182d) This commit simply copies directly from it. The config part has been merged into hyper 1.0 (https://github.com/hyperium/hyper/pull/3507). This commit completes the re-addition of this missing function. --- src/client/legacy/client.rs | 16 ++++++++++++++++ src/server/conn/auto.rs | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/client/legacy/client.rs b/src/client/legacy/client.rs index 48b17dbf..3d43d321 100644 --- a/src/client/legacy/client.rs +++ b/src/client/legacy/client.rs @@ -1238,6 +1238,22 @@ impl Builder { 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 for more information. + #[cfg(feature = "http2")] + #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] + pub fn http2_max_pending_accept_reset_streams( + &mut self, + max: impl Into>, + ) -> &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. /// diff --git a/src/server/conn/auto.rs b/src/server/conn/auto.rs index 36610a12..05fada87 100644 --- a/src/server/conn/auto.rs +++ b/src/server/conn/auto.rs @@ -551,6 +551,17 @@ impl Http2Builder<'_, 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 for more information. + pub fn max_pending_accept_reset_streams(mut self, max: impl Into>) -> Self { + self.protocol.http2_max_pending_accept_reset_streams(max); + self + } + /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2 /// stream-level flow control. ///