diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 253a7c050..442af71cb 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -75,7 +75,7 @@ async-trait = {version = "0.1.13", optional = true} # transport h2 = {version = "0.4", optional = true} hyper = {version = "1", features = ["http1", "http2"], optional = true} -hyper-util = { version = "0.1.4", features = ["tokio"], optional = true } +hyper-util = { version = "0.1.11", features = ["tokio"], optional = true } socket2 = { version = "0.6", optional = true, features = ["all"] } tokio = {version = "1", default-features = false, optional = true} tower = {version = "0.5", default-features = false, optional = true} diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index ce84e75c8..9112443ba 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -103,6 +103,7 @@ pub struct Server { http2_keepalive_timeout: Duration, http2_adaptive_window: Option, http2_max_pending_accept_reset_streams: Option, + http2_max_local_error_reset_streams: Option, http2_max_header_list_size: Option, max_frame_size: Option, accept_http1: bool, @@ -128,6 +129,7 @@ impl Default for Server { http2_keepalive_timeout: DEFAULT_HTTP2_KEEPALIVE_TIMEOUT, http2_adaptive_window: None, http2_max_pending_accept_reset_streams: None, + http2_max_local_error_reset_streams: None, http2_max_header_list_size: None, max_frame_size: None, accept_http1: false, @@ -340,6 +342,17 @@ impl Server { } } + /// Configures the maximum number of local reset streams allowed before a GOAWAY will be sent. + /// + /// This will default to whatever the default in hyper is. + #[must_use] + pub fn http2_max_local_error_reset_streams(self, max: Option) -> Self { + Server { + http2_max_local_error_reset_streams: max, + ..self + } + } + /// Set whether TCP keepalive messages are enabled on accepted connections. /// /// If `None` is specified, keepalive is disabled, otherwise the duration @@ -556,6 +569,7 @@ impl Server { http2_adaptive_window: self.http2_adaptive_window, http2_max_pending_accept_reset_streams: self.http2_max_pending_accept_reset_streams, http2_max_header_list_size: self.http2_max_header_list_size, + http2_max_local_error_reset_streams: self.http2_max_local_error_reset_streams, max_frame_size: self.max_frame_size, accept_http1: self.accept_http1, max_connection_age: self.max_connection_age, @@ -685,6 +699,7 @@ impl Server { let http2_keepalive_timeout = self.http2_keepalive_timeout; let http2_adaptive_window = self.http2_adaptive_window; let http2_max_pending_accept_reset_streams = self.http2_max_pending_accept_reset_streams; + let http2_max_local_error_reset_streams = self.http2_max_local_error_reset_streams; let max_connection_age = self.max_connection_age; let svc = self.service_builder.service(svc); @@ -720,6 +735,7 @@ impl Server { .keep_alive_timeout(http2_keepalive_timeout) .adaptive_window(http2_adaptive_window.unwrap_or_default()) .max_pending_accept_reset_streams(http2_max_pending_accept_reset_streams) + .max_local_error_reset_streams(http2_max_local_error_reset_streams) .max_frame_size(max_frame_size); if let Some(max_header_list_size) = max_header_list_size {