File tree 3 files changed +38
-5
lines changed
3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,11 @@ where
66
66
}
67
67
68
68
pub fn set_flush_pipeline ( & mut self , enabled : bool ) {
69
+ debug_assert ! ( !self . write_buf. has_remaining( ) ) ;
69
70
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
+ }
75
74
}
76
75
77
76
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};
37
37
#[ derive( Clone , Debug ) ]
38
38
pub struct Http {
39
39
exec : Exec ,
40
+ h1_writev : bool ,
40
41
mode : ConnectionMode ,
41
42
keep_alive : bool ,
42
43
max_buf_size : Option < usize > ,
@@ -138,6 +139,7 @@ impl Http {
138
139
pub fn new ( ) -> Http {
139
140
Http {
140
141
exec : Exec :: Default ,
142
+ h1_writev : true ,
141
143
mode : ConnectionMode :: Fallback ,
142
144
keep_alive : true ,
143
145
max_buf_size : None ,
@@ -157,6 +159,20 @@ impl Http {
157
159
self
158
160
}
159
161
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
+
160
176
/// Sets whether HTTP2 is required.
161
177
///
162
178
/// Default is false
@@ -264,6 +280,9 @@ impl Http {
264
280
if !self . keep_alive {
265
281
conn. disable_keep_alive ( ) ;
266
282
}
283
+ if !self . h1_writev {
284
+ conn. set_write_strategy_flatten ( ) ;
285
+ }
267
286
conn. set_flush_pipeline ( self . pipeline_flush ) ;
268
287
if let Some ( max) = self . max_buf_size {
269
288
conn. set_max_buf_size ( max) ;
Original file line number Diff line number Diff line change @@ -175,6 +175,21 @@ impl<I> Builder<I> {
175
175
self
176
176
}
177
177
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
+
178
193
/// Sets whether HTTP/2 is required.
179
194
///
180
195
/// Default is `false`.
You can’t perform that action at this time.
0 commit comments