Skip to content

Commit 6cd8607

Browse files
magurotunaRalith
authored andcommitted
feat(http2): add initial_max_send_streams method to HTTP/2 client builder (hyperium#3524)
1 parent 72ebcff commit 6cd8607

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/client/conn/http2.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,19 @@ impl Builder {
293293
self
294294
}
295295

296+
/// Sets the initial maximum of locally initiated (send) streams.
297+
///
298+
/// This value will be overwritten by the value included in the initial
299+
/// SETTINGS frame received from the peer as part of a [connection preface].
300+
///
301+
/// The default value is determined by the `h2` crate, but may change.
302+
///
303+
/// [connection preface]: https://httpwg.org/specs/rfc9113.html#preface
304+
pub fn initial_max_send_streams(&mut self, initial: impl Into<Option<usize>>) -> &mut Self {
305+
self.h2_builder.initial_max_send_streams = initial.into();
306+
self
307+
}
308+
296309
/// Sets whether to use an adaptive flow control.
297310
///
298311
/// Enabling this will override the limits set in

src/proto/h2/client.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub(crate) struct Config {
5252
pub(crate) adaptive_window: bool,
5353
pub(crate) initial_conn_window_size: u32,
5454
pub(crate) initial_stream_window_size: u32,
55+
pub(crate) initial_max_send_streams: Option<usize>,
5556
pub(crate) max_frame_size: u32,
5657
#[cfg(feature = "runtime")]
5758
pub(crate) keep_alive_interval: Option<Duration>,
@@ -69,6 +70,7 @@ impl Default for Config {
6970
adaptive_window: false,
7071
initial_conn_window_size: DEFAULT_CONN_WINDOW,
7172
initial_stream_window_size: DEFAULT_STREAM_WINDOW,
73+
initial_max_send_streams: None,
7274
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
7375
#[cfg(feature = "runtime")]
7476
keep_alive_interval: None,
@@ -90,6 +92,9 @@ fn new_builder(config: &Config) -> Builder {
9092
.max_frame_size(config.max_frame_size)
9193
.max_send_buffer_size(config.max_send_buffer_size)
9294
.enable_push(false);
95+
if let Some(initial_max_send_streams) = config.initial_max_send_streams {
96+
builder.initial_max_send_streams(initial_max_send_streams);
97+
}
9398
if let Some(max) = config.max_concurrent_reset_streams {
9499
builder.max_concurrent_reset_streams(max);
95100
}

0 commit comments

Comments
 (0)