@@ -75,6 +75,7 @@ pub struct Builder {
75
75
h1_writev : bool ,
76
76
h1_title_case_headers : bool ,
77
77
h1_read_buf_exact_size : Option < usize > ,
78
+ h1_max_buf_size : Option < usize > ,
78
79
http2 : bool ,
79
80
}
80
81
@@ -435,6 +436,7 @@ impl Builder {
435
436
h1_writev : true ,
436
437
h1_read_buf_exact_size : None ,
437
438
h1_title_case_headers : false ,
439
+ h1_max_buf_size : None ,
438
440
http2 : false ,
439
441
}
440
442
}
@@ -460,8 +462,21 @@ impl Builder {
460
462
461
463
pub ( super ) fn h1_read_buf_exact_size ( & mut self , sz : Option < usize > ) -> & mut Builder {
462
464
self . h1_read_buf_exact_size = sz;
465
+ self . h1_max_buf_size = None ;
463
466
self
464
467
}
468
+
469
+ pub ( super ) fn h1_max_buf_size ( & mut self , max : usize ) -> & mut Self {
470
+ assert ! (
471
+ max >= proto:: h1:: MINIMUM_MAX_BUFFER_SIZE ,
472
+ "the max_buf_size cannot be smaller than the minimum that h1 specifies."
473
+ ) ;
474
+
475
+ self . h1_max_buf_size = Some ( max) ;
476
+ self . h1_read_buf_exact_size = None ;
477
+ self
478
+ }
479
+
465
480
/// Sets whether HTTP2 is required.
466
481
///
467
482
/// Default is false.
@@ -510,6 +525,9 @@ where
510
525
if let Some ( sz) = self . builder . h1_read_buf_exact_size {
511
526
conn. set_read_buf_exact_size ( sz) ;
512
527
}
528
+ if let Some ( max) = self . builder . h1_max_buf_size {
529
+ conn. set_max_buf_size ( max) ;
530
+ }
513
531
let cd = proto:: h1:: dispatch:: Client :: new ( rx) ;
514
532
let dispatch = proto:: h1:: Dispatcher :: new ( cd, conn) ;
515
533
Either :: A ( dispatch)
0 commit comments