@@ -170,6 +170,7 @@ pub struct HttpConnector {
170
170
enforce_http : bool ,
171
171
handle : Option < Handle > ,
172
172
keep_alive_timeout : Option < Duration > ,
173
+ nodelay : bool ,
173
174
}
174
175
175
176
impl HttpConnector {
@@ -205,6 +206,7 @@ impl HttpConnector {
205
206
enforce_http : true ,
206
207
handle,
207
208
keep_alive_timeout : None ,
209
+ nodelay : false ,
208
210
}
209
211
}
210
212
@@ -225,6 +227,14 @@ impl HttpConnector {
225
227
pub fn set_keepalive ( & mut self , dur : Option < Duration > ) {
226
228
self . keep_alive_timeout = dur;
227
229
}
230
+
231
+ /// Set that all sockets have `SO_NODELAY` set to the supplied value `nodelay`.
232
+ ///
233
+ /// Default is `false`.
234
+ #[ inline]
235
+ pub fn set_nodelay ( & mut self , nodelay : bool ) {
236
+ self . nodelay = nodelay;
237
+ }
228
238
}
229
239
230
240
impl fmt:: Debug for HttpConnector {
@@ -264,6 +274,7 @@ impl Connect for HttpConnector {
264
274
state : State :: Lazy ( self . executor . clone ( ) , host. into ( ) , port) ,
265
275
handle : self . handle . clone ( ) ,
266
276
keep_alive_timeout : self . keep_alive_timeout ,
277
+ nodelay : self . nodelay ,
267
278
}
268
279
}
269
280
}
@@ -274,6 +285,7 @@ fn invalid_url(err: InvalidUrl, handle: &Option<Handle>) -> HttpConnecting {
274
285
state : State :: Error ( Some ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , err) ) ) ,
275
286
handle : handle. clone ( ) ,
276
287
keep_alive_timeout : None ,
288
+ nodelay : false ,
277
289
}
278
290
}
279
291
@@ -306,6 +318,7 @@ pub struct HttpConnecting {
306
318
state : State ,
307
319
handle : Option < Handle > ,
308
320
keep_alive_timeout : Option < Duration > ,
321
+ nodelay : bool ,
309
322
}
310
323
311
324
enum State {
@@ -355,6 +368,8 @@ impl Future for HttpConnecting {
355
368
sock. set_keepalive ( Some ( dur) ) ?;
356
369
}
357
370
371
+ sock. set_nodelay ( self . nodelay ) ?;
372
+
358
373
return Ok ( Async :: Ready ( ( sock, Connected :: new ( ) ) ) ) ;
359
374
} ,
360
375
State :: Error ( ref mut e) => return Err ( e. take ( ) . expect ( "polled more than once" ) ) ,
0 commit comments