@@ -15,6 +15,7 @@ use std::sync::Arc;
1515use bytes:: Bytes ;
1616use futures:: { Async , Future , Poll } ;
1717use futures:: future:: { self , Either , Executor } ;
18+ use h2;
1819use tokio_io:: { AsyncRead , AsyncWrite } ;
1920
2021use body:: Payload ;
@@ -77,6 +78,7 @@ pub struct Builder {
7778 h1_read_buf_exact_size : Option < usize > ,
7879 h1_max_buf_size : Option < usize > ,
7980 http2 : bool ,
81+ h2_builder : h2:: client:: Builder ,
8082}
8183
8284/// A future setting up HTTP over an IO object.
@@ -431,13 +433,17 @@ impl Builder {
431433 /// Creates a new connection builder.
432434 #[ inline]
433435 pub fn new ( ) -> Builder {
436+ let mut h2_builder = h2:: client:: Builder :: default ( ) ;
437+ h2_builder. enable_push ( false ) ;
438+
434439 Builder {
435440 exec : Exec :: Default ,
436441 h1_writev : true ,
437442 h1_read_buf_exact_size : None ,
438443 h1_title_case_headers : false ,
439444 h1_max_buf_size : None ,
440445 http2 : false ,
446+ h2_builder,
441447 }
442448 }
443449
@@ -485,6 +491,29 @@ impl Builder {
485491 self
486492 }
487493
494+ /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
495+ /// stream-level flow control.
496+ ///
497+ /// Default is 65,535
498+ ///
499+ /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
500+ pub fn http2_initial_stream_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
501+ if let Some ( sz) = sz. into ( ) {
502+ self . h2_builder . initial_window_size ( sz) ;
503+ }
504+ self
505+ }
506+
507+ /// Sets the max connection-level flow control for HTTP2
508+ ///
509+ /// Default is 65,535
510+ pub fn http2_initial_connection_window_size ( & mut self , sz : impl Into < Option < u32 > > ) -> & mut Self {
511+ if let Some ( sz) = sz. into ( ) {
512+ self . h2_builder . initial_connection_window_size ( sz) ;
513+ }
514+ self
515+ }
516+
488517 /// Constructs a connection with the configured options and IO.
489518 #[ inline]
490519 pub fn handshake < T , B > ( & self , io : T ) -> Handshake < T , B >
@@ -532,7 +561,7 @@ where
532561 let dispatch = proto:: h1:: Dispatcher :: new ( cd, conn) ;
533562 Either :: A ( dispatch)
534563 } else {
535- let h2 = proto:: h2:: Client :: new ( io, rx, self . builder . exec . clone ( ) ) ;
564+ let h2 = proto:: h2:: Client :: new ( io, rx, & self . builder . h2_builder , self . builder . exec . clone ( ) ) ;
536565 Either :: B ( h2)
537566 } ;
538567
0 commit comments