@@ -47,6 +47,9 @@ pub struct Server {
47
47
// timeout: Option<Duration>,
48
48
#[ cfg( feature = "tls" ) ]
49
49
tls : Option < TlsAcceptor > ,
50
+ init_stream_window_size : Option < u32 > ,
51
+ init_connection_window_size : Option < u32 > ,
52
+ max_concurrent_streams : Option < u32 > ,
50
53
}
51
54
52
55
impl Server {
@@ -123,6 +126,36 @@ impl Server {
123
126
// self
124
127
// }
125
128
129
+ /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
130
+ /// stream-level flow control.
131
+ ///
132
+ /// Default is 65,535
133
+ ///
134
+ /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
135
+ pub fn initial_stream_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
136
+ self . init_stream_window_size = sz. into ( ) ;
137
+ self
138
+ }
139
+
140
+ /// Sets the max connection-level flow control for HTTP2
141
+ ///
142
+ /// Default is 65,535
143
+ pub fn initial_connection_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
144
+ self . init_connection_window_size = sz. into ( ) ;
145
+ self
146
+ }
147
+
148
+ /// Sets the [`SETTINGS_MAX_CONCURRENT_STREAMS`][spec] option for HTTP2
149
+ /// connections.
150
+ ///
151
+ /// Default is no limit (`None`).
152
+ ///
153
+ /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_MAX_CONCURRENT_STREAMS
154
+ pub fn max_concurrent_streams ( & mut self , max : impl Into < Option < u32 > > ) -> & mut Self {
155
+ self . max_concurrent_streams = max. into ( ) ;
156
+ self
157
+ }
158
+
126
159
/// Intercept the execution of gRPC methods.
127
160
///
128
161
/// ```
@@ -162,6 +195,9 @@ impl Server {
162
195
{
163
196
let interceptor = self . interceptor . clone ( ) ;
164
197
let concurrency_limit = self . concurrency_limit ;
198
+ let init_connection_window_size = self . init_connection_window_size ;
199
+ let init_stream_window_size = self . init_stream_window_size ;
200
+ let max_concurrent_streams = self . max_concurrent_streams ;
165
201
// let timeout = self.timeout.clone();
166
202
167
203
let incoming = hyper:: server:: accept:: from_stream ( async_stream:: try_stream! {
@@ -190,6 +226,9 @@ impl Server {
190
226
191
227
hyper:: Server :: builder ( incoming)
192
228
. http2_only ( true )
229
+ . http2_initial_connection_window_size ( init_connection_window_size)
230
+ . http2_initial_stream_window_size ( init_stream_window_size)
231
+ . http2_max_concurrent_streams ( max_concurrent_streams)
193
232
. serve ( svc)
194
233
. await
195
234
. map_err ( map_err) ?;
0 commit comments