@@ -15,6 +15,7 @@ use std::sync::Arc;
15
15
use bytes:: Bytes ;
16
16
use futures:: { Async , Future , Poll } ;
17
17
use futures:: future:: { self , Either , Executor } ;
18
+ use h2;
18
19
use tokio_io:: { AsyncRead , AsyncWrite } ;
19
20
20
21
use body:: Payload ;
@@ -77,6 +78,7 @@ pub struct Builder {
77
78
h1_read_buf_exact_size : Option < usize > ,
78
79
h1_max_buf_size : Option < usize > ,
79
80
http2 : bool ,
81
+ h2_builder : h2:: client:: Builder ,
80
82
}
81
83
82
84
/// A future setting up HTTP over an IO object.
@@ -431,13 +433,17 @@ impl Builder {
431
433
/// Creates a new connection builder.
432
434
#[ inline]
433
435
pub fn new ( ) -> Builder {
436
+ let mut h2_builder = h2:: client:: Builder :: default ( ) ;
437
+ h2_builder. enable_push ( false ) ;
438
+
434
439
Builder {
435
440
exec : Exec :: Default ,
436
441
h1_writev : true ,
437
442
h1_read_buf_exact_size : None ,
438
443
h1_title_case_headers : false ,
439
444
h1_max_buf_size : None ,
440
445
http2 : false ,
446
+ h2_builder,
441
447
}
442
448
}
443
449
@@ -485,6 +491,29 @@ impl Builder {
485
491
self
486
492
}
487
493
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
+
488
517
/// Constructs a connection with the configured options and IO.
489
518
#[ inline]
490
519
pub fn handshake < T , B > ( & self , io : T ) -> Handshake < T , B >
@@ -532,7 +561,7 @@ where
532
561
let dispatch = proto:: h1:: Dispatcher :: new ( cd, conn) ;
533
562
Either :: A ( dispatch)
534
563
} 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 ( ) ) ;
536
565
Either :: B ( h2)
537
566
} ;
538
567
0 commit comments