Skip to content

Commit

Permalink
feat(http2): add initial_max_send_streams method to HTTP/2 client b…
Browse files Browse the repository at this point in the history
…uilder (#3524)
  • Loading branch information
magurotuna authored Jan 19, 2024
1 parent 8241f91 commit fdfa60d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ where
self
}

/// Sets the initial maximum of locally initiated (send) streams.
///
/// This value will be overwritten by the value included in the initial
/// SETTINGS frame received from the peer as part of a [connection preface].
///
/// The default value is determined by the `h2` crate, but may change.
///
/// [connection preface]: https://httpwg.org/specs/rfc9113.html#preface
pub fn initial_max_send_streams(&mut self, initial: impl Into<Option<usize>>) -> &mut Self {
self.h2_builder.initial_max_send_streams = initial.into();
self
}

/// Sets whether to use an adaptive flow control.
///
/// Enabling this will override the limits set in
Expand Down
5 changes: 5 additions & 0 deletions src/proto/h2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub(crate) struct Config {
pub(crate) adaptive_window: bool,
pub(crate) initial_conn_window_size: u32,
pub(crate) initial_stream_window_size: u32,
pub(crate) initial_max_send_streams: Option<usize>,
pub(crate) max_frame_size: u32,
pub(crate) keep_alive_interval: Option<Duration>,
pub(crate) keep_alive_timeout: Duration,
Expand All @@ -71,6 +72,7 @@ impl Default for Config {
adaptive_window: false,
initial_conn_window_size: DEFAULT_CONN_WINDOW,
initial_stream_window_size: DEFAULT_STREAM_WINDOW,
initial_max_send_streams: None,
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
keep_alive_interval: None,
keep_alive_timeout: Duration::from_secs(20),
Expand All @@ -89,6 +91,9 @@ fn new_builder(config: &Config) -> Builder {
.max_frame_size(config.max_frame_size)
.max_send_buffer_size(config.max_send_buffer_size)
.enable_push(false);
if let Some(initial_max_send_streams) = config.initial_max_send_streams {
builder.initial_max_send_streams(initial_max_send_streams);
}
if let Some(max) = config.max_concurrent_reset_streams {
builder.max_concurrent_reset_streams(max);
}
Expand Down

0 comments on commit fdfa60d

Please sign in to comment.