Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 16 additions & 0 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub struct Server<L = Identity> {
http2_keepalive_timeout: Duration,
http2_adaptive_window: Option<bool>,
http2_max_pending_accept_reset_streams: Option<usize>,
http2_max_local_error_reset_streams: Option<usize>,
http2_max_header_list_size: Option<u32>,
max_frame_size: Option<u32>,
accept_http1: bool,
Expand All @@ -128,6 +129,7 @@ impl Default for Server<Identity> {
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,
Expand Down Expand Up @@ -340,6 +342,17 @@ impl<L> Server<L> {
}
}

/// 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<usize>) -> 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
Expand Down Expand Up @@ -556,6 +569,7 @@ impl<L> Server<L> {
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,
Expand Down Expand Up @@ -685,6 +699,7 @@ impl<L> Server<L> {
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);
Expand Down Expand Up @@ -720,6 +735,7 @@ impl<L> Server<L> {
.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 {
Expand Down
Loading