@@ -103,6 +103,7 @@ pub struct Http<E = Exec> {
103
103
h1_keep_alive : bool ,
104
104
h1_title_case_headers : bool ,
105
105
h1_preserve_header_case : bool ,
106
+ h1_writev : Option < bool > ,
106
107
#[ cfg( feature = "http2" ) ]
107
108
h2_builder : proto:: h2:: server:: Config ,
108
109
mode : ConnectionMode ,
@@ -284,6 +285,7 @@ impl Http {
284
285
h1_keep_alive : true ,
285
286
h1_title_case_headers : false ,
286
287
h1_preserve_header_case : false ,
288
+ h1_writev : None ,
287
289
#[ cfg( feature = "http2" ) ]
288
290
h2_builder : Default :: default ( ) ,
289
291
mode : ConnectionMode :: default ( ) ,
@@ -363,6 +365,26 @@ impl<E> Http<E> {
363
365
self
364
366
}
365
367
368
+ /// Set whether HTTP/1 connections should try to use vectored writes,
369
+ /// or always flatten into a single buffer.
370
+ ///
371
+ /// Note that setting this to false may mean more copies of body data,
372
+ /// but may also improve performance when an IO transport doesn't
373
+ /// support vectored writes well, such as most TLS implementations.
374
+ ///
375
+ /// Setting this to true will force hyper to use queued strategy
376
+ /// which may eliminate unnecessary cloning on some TLS backends
377
+ ///
378
+ /// Default is `auto`. In this mode hyper will try to guess which
379
+ /// mode to use
380
+ #[ inline]
381
+ #[ cfg( feature = "http1" ) ]
382
+ #[ cfg_attr( docsrs, doc( cfg( feature = "http1" ) ) ) ]
383
+ pub fn http1_writev ( & mut self , val : bool ) -> & mut Self {
384
+ self . h1_writev = Some ( val) ;
385
+ self
386
+ }
387
+
366
388
/// Sets whether HTTP2 is required.
367
389
///
368
390
/// Default is false
@@ -538,6 +560,7 @@ impl<E> Http<E> {
538
560
h1_keep_alive : self . h1_keep_alive ,
539
561
h1_title_case_headers : self . h1_title_case_headers ,
540
562
h1_preserve_header_case : self . h1_preserve_header_case ,
563
+ h1_writev : self . h1_writev ,
541
564
#[ cfg( feature = "http2" ) ]
542
565
h2_builder : self . h2_builder ,
543
566
mode : self . mode ,
@@ -599,6 +622,13 @@ impl<E> Http<E> {
599
622
if self . h1_preserve_header_case {
600
623
conn. set_preserve_header_case( ) ;
601
624
}
625
+ if let Some ( writev) = self . h1_writev {
626
+ if writev {
627
+ conn. set_write_strategy_queue( ) ;
628
+ } else {
629
+ conn. set_write_strategy_flatten( ) ;
630
+ }
631
+ }
602
632
conn. set_flush_pipeline( self . pipeline_flush) ;
603
633
if let Some ( max) = self . max_buf_size {
604
634
conn. set_max_buf_size( max) ;
0 commit comments