Skip to content

Commit fdfa60d

Browse files
authoredJan 19, 2024
feat(http2): add initial_max_send_streams method to HTTP/2 client builder (#3524)
1 parent 8241f91 commit fdfa60d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

Diff for: ‎src/client/conn/http2.rs

+13
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ where
305305
self
306306
}
307307

308+
/// Sets the initial maximum of locally initiated (send) streams.
309+
///
310+
/// This value will be overwritten by the value included in the initial
311+
/// SETTINGS frame received from the peer as part of a [connection preface].
312+
///
313+
/// The default value is determined by the `h2` crate, but may change.
314+
///
315+
/// [connection preface]: https://httpwg.org/specs/rfc9113.html#preface
316+
pub fn initial_max_send_streams(&mut self, initial: impl Into<Option<usize>>) -> &mut Self {
317+
self.h2_builder.initial_max_send_streams = initial.into();
318+
self
319+
}
320+
308321
/// Sets whether to use an adaptive flow control.
309322
///
310323
/// Enabling this will override the limits set in

Diff for: ‎src/proto/h2/client.rs

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub(crate) struct Config {
5757
pub(crate) adaptive_window: bool,
5858
pub(crate) initial_conn_window_size: u32,
5959
pub(crate) initial_stream_window_size: u32,
60+
pub(crate) initial_max_send_streams: Option<usize>,
6061
pub(crate) max_frame_size: u32,
6162
pub(crate) keep_alive_interval: Option<Duration>,
6263
pub(crate) keep_alive_timeout: Duration,
@@ -71,6 +72,7 @@ impl Default for Config {
7172
adaptive_window: false,
7273
initial_conn_window_size: DEFAULT_CONN_WINDOW,
7374
initial_stream_window_size: DEFAULT_STREAM_WINDOW,
75+
initial_max_send_streams: None,
7476
max_frame_size: DEFAULT_MAX_FRAME_SIZE,
7577
keep_alive_interval: None,
7678
keep_alive_timeout: Duration::from_secs(20),
@@ -89,6 +91,9 @@ fn new_builder(config: &Config) -> Builder {
8991
.max_frame_size(config.max_frame_size)
9092
.max_send_buffer_size(config.max_send_buffer_size)
9193
.enable_push(false);
94+
if let Some(initial_max_send_streams) = config.initial_max_send_streams {
95+
builder.initial_max_send_streams(initial_max_send_streams);
96+
}
9297
if let Some(max) = config.max_concurrent_reset_streams {
9398
builder.max_concurrent_reset_streams(max);
9499
}

0 commit comments

Comments
 (0)
Please sign in to comment.