Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2: add max_pending_accept_reset_streams configuration option #3201

Merged
merged 7 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ categories = ["network-programming", "web-programming::http-client", "web-progra
edition = "2018"

include = [
"Cargo.toml",
"LICENSE",
"src/**/*",
#"build.rs",
"Cargo.toml",
"LICENSE",
"src/**/*",
#"build.rs",
Noah-Kennedy marked this conversation as resolved.
Show resolved Hide resolved
]

[dependencies]
Expand All @@ -28,7 +28,7 @@ http = "0.2"
http-body = "0.4"
httpdate = "1.0"
httparse = "1.8"
h2 = { version = "0.3.9", optional = true }
h2 = { version = "0.3.17", optional = true }
itoa = "1"
tracing = { version = "0.1", default-features = false, features = ["std"] }
pin-project-lite = "0.2.4"
Expand Down
8 changes: 6 additions & 2 deletions src/proto/h2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024; // 1mb
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024; // 1mb
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 400; // 400kb
// 16 MB "sane default" taken from golang http2
// 16 MB "sane default" taken from golang http2
Noah-Kennedy marked this conversation as resolved.
Show resolved Hide resolved
Noah-Kennedy marked this conversation as resolved.
Show resolved Hide resolved
const DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: u32 = 16 << 20;

#[derive(Clone, Debug)]
Expand All @@ -46,6 +46,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>,
#[cfg(feature = "runtime")]
pub(crate) keep_alive_interval: Option<Duration>,
#[cfg(feature = "runtime")]
Expand All @@ -63,6 +64,7 @@ impl Default for Config {
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
enable_connect_protocol: false,
max_concurrent_streams: None,
max_pending_accept_reset_streams: None,
#[cfg(feature = "runtime")]
keep_alive_interval: None,
#[cfg(feature = "runtime")]
Expand Down Expand Up @@ -125,6 +127,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 Expand Up @@ -503,7 +508,6 @@ where
}
}


if !body.is_end_stream() {
// automatically set Content-Length from body...
if let Some(len) = body.size_hint().exact() {
Expand Down
11 changes: 11 additions & 0 deletions src/server/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ impl<E> Http<E> {
self
}

/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
///
/// See <https://github.com/hyperium/hyper/issues/2877> for more information.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn http2_max_pending_accept_reset_streams(&mut self, max: usize) -> &mut Self {
Noah-Kennedy marked this conversation as resolved.
Show resolved Hide resolved
self.h2_builder.max_pending_accept_reset_streams = Some(max);

self
}

/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
/// stream-level flow control.
///
Expand Down
10 changes: 10 additions & 0 deletions src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ impl<I, E> Builder<I, E> {
self
}

/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
///
/// See <https://github.com/hyperium/hyper/issues/2877> for more information.
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn http2_max_pending_accept_reset_streams(mut self, max: usize) -> 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.
///
Expand Down