File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,11 @@ where
6666 }
6767
6868 pub fn set_flush_pipeline ( & mut self , enabled : bool ) {
69+ debug_assert ! ( !self . write_buf. has_remaining( ) ) ;
6970 self . flush_pipeline = enabled;
70- self . write_buf . set_strategy ( if enabled {
71- Strategy :: Flatten
72- } else {
73- Strategy :: Auto
74- } ) ;
71+ if enabled {
72+ self . set_write_strategy_flatten ( ) ;
73+ }
7574 }
7675
7776 pub fn set_max_buf_size ( & mut self , max : usize ) {
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ use error::{Kind, Parse};
3737#[ derive( Clone , Debug ) ]
3838pub struct Http {
3939 exec : Exec ,
40+ h1_writev : bool ,
4041 mode : ConnectionMode ,
4142 keep_alive : bool ,
4243 max_buf_size : Option < usize > ,
@@ -138,6 +139,7 @@ impl Http {
138139 pub fn new ( ) -> Http {
139140 Http {
140141 exec : Exec :: Default ,
142+ h1_writev : true ,
141143 mode : ConnectionMode :: Fallback ,
142144 keep_alive : true ,
143145 max_buf_size : None ,
@@ -157,6 +159,20 @@ impl Http {
157159 self
158160 }
159161
162+ /// Set whether HTTP/1 connections should try to use vectored writes,
163+ /// or always flatten into a single buffer.
164+ ///
165+ /// Note that setting this to false may mean more copies of body data,
166+ /// but may also improve performance when an IO transport doesn't
167+ /// support vectored writes well, such as most TLS implementations.
168+ ///
169+ /// Default is `true`.
170+ #[ inline]
171+ pub fn http1_writev ( & mut self , val : bool ) -> & mut Self {
172+ self . h1_writev = val;
173+ self
174+ }
175+
160176 /// Sets whether HTTP2 is required.
161177 ///
162178 /// Default is false
@@ -264,6 +280,9 @@ impl Http {
264280 if !self . keep_alive {
265281 conn. disable_keep_alive ( ) ;
266282 }
283+ if !self . h1_writev {
284+ conn. set_write_strategy_flatten ( ) ;
285+ }
267286 conn. set_flush_pipeline ( self . pipeline_flush ) ;
268287 if let Some ( max) = self . max_buf_size {
269288 conn. set_max_buf_size ( max) ;
Original file line number Diff line number Diff line change @@ -175,6 +175,21 @@ impl<I> Builder<I> {
175175 self
176176 }
177177
178+ /// Set whether HTTP/1 connections should try to use vectored writes,
179+ /// or always flatten into a single buffer.
180+ ///
181+ /// # Note
182+ ///
183+ /// Setting this to `false` may mean more copies of body data,
184+ /// but may also improve performance when an IO transport doesn't
185+ /// support vectored writes well, such as most TLS implementations.
186+ ///
187+ /// Default is `true`.
188+ pub fn http1_writev ( mut self , val : bool ) -> Self {
189+ self . protocol . http1_writev ( val) ;
190+ self
191+ }
192+
178193 /// Sets whether HTTP/2 is required.
179194 ///
180195 /// Default is `false`.
You can’t perform that action at this time.
0 commit comments