@@ -52,11 +52,21 @@ const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb
52
52
const DEFAULT_MAX_FRAME_SIZE : u32 = 1024 * 16 ; // 16kb
53
53
const DEFAULT_MAX_SEND_BUF_SIZE : usize = 1024 * 1024 ; // 1mb
54
54
55
+ // The maximum number of concurrent streams that the client is allowed to open
56
+ // before it receives the initial SETTINGS frame from the server.
57
+ // This default value is derived from what the HTTP/2 spec recommends as the
58
+ // minimum value that endpoints advertise to their peers. It means that using
59
+ // this value will minimize the chance of the failure where the local endpoint
60
+ // attempts to open too many streams and gets rejected by the remote peer with
61
+ // the `REFUSED_STREAM` error.
62
+ const DEFAULT_INITIAL_MAX_SEND_STREAMS : usize = 100 ;
63
+
55
64
#[ derive( Clone , Debug ) ]
56
65
pub ( crate ) struct Config {
57
66
pub ( crate ) adaptive_window : bool ,
58
67
pub ( crate ) initial_conn_window_size : u32 ,
59
68
pub ( crate ) initial_stream_window_size : u32 ,
69
+ pub ( crate ) initial_max_send_streams : usize ,
60
70
pub ( crate ) max_frame_size : u32 ,
61
71
pub ( crate ) keep_alive_interval : Option < Duration > ,
62
72
pub ( crate ) keep_alive_timeout : Duration ,
@@ -71,6 +81,7 @@ impl Default for Config {
71
81
adaptive_window : false ,
72
82
initial_conn_window_size : DEFAULT_CONN_WINDOW ,
73
83
initial_stream_window_size : DEFAULT_STREAM_WINDOW ,
84
+ initial_max_send_streams : DEFAULT_INITIAL_MAX_SEND_STREAMS ,
74
85
max_frame_size : DEFAULT_MAX_FRAME_SIZE ,
75
86
keep_alive_interval : None ,
76
87
keep_alive_timeout : Duration :: from_secs ( 20 ) ,
@@ -84,6 +95,7 @@ impl Default for Config {
84
95
fn new_builder ( config : & Config ) -> Builder {
85
96
let mut builder = Builder :: default ( ) ;
86
97
builder
98
+ . initial_max_send_streams ( config. initial_max_send_streams )
87
99
. initial_window_size ( config. initial_stream_window_size )
88
100
. initial_connection_window_size ( config. initial_conn_window_size )
89
101
. max_frame_size ( config. max_frame_size )
0 commit comments