@@ -103,6 +103,7 @@ pub struct Http<E = Exec> {
103103 h1_keep_alive : bool ,
104104 h1_title_case_headers : bool ,
105105 h1_preserve_header_case : bool ,
106+ h1_writev : Option < bool > ,
106107 #[ cfg( feature = "http2" ) ]
107108 h2_builder : proto:: h2:: server:: Config ,
108109 mode : ConnectionMode ,
@@ -284,6 +285,7 @@ impl Http {
284285 h1_keep_alive : true ,
285286 h1_title_case_headers : false ,
286287 h1_preserve_header_case : false ,
288+ h1_writev : None ,
287289 #[ cfg( feature = "http2" ) ]
288290 h2_builder : Default :: default ( ) ,
289291 mode : ConnectionMode :: default ( ) ,
@@ -363,6 +365,26 @@ impl<E> Http<E> {
363365 self
364366 }
365367
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+
366388 /// Sets whether HTTP2 is required.
367389 ///
368390 /// Default is false
@@ -538,6 +560,7 @@ impl<E> Http<E> {
538560 h1_keep_alive : self . h1_keep_alive ,
539561 h1_title_case_headers : self . h1_title_case_headers ,
540562 h1_preserve_header_case : self . h1_preserve_header_case ,
563+ h1_writev : self . h1_writev ,
541564 #[ cfg( feature = "http2" ) ]
542565 h2_builder : self . h2_builder ,
543566 mode : self . mode ,
@@ -599,6 +622,13 @@ impl<E> Http<E> {
599622 if self . h1_preserve_header_case {
600623 conn. set_preserve_header_case( ) ;
601624 }
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+ }
602632 conn. set_flush_pipeline( self . pipeline_flush) ;
603633 if let Some ( max) = self . max_buf_size {
604634 conn. set_max_buf_size( max) ;
0 commit comments