perf(client): set TCP keepalive when default connector is used

This commit is contained in:
Sean McArthur
2018-02-15 12:40:38 -08:00
parent ee61ea9adf
commit 6ef22da8ea
2 changed files with 31 additions and 16 deletions

View File

@@ -544,7 +544,11 @@ where B: Stream<Error=::Error>,
/// Construct the Client with this configuration.
#[inline]
pub fn build(self, handle: &Handle) -> Client<HttpConnector, B> {
self.connector(HttpConnector::new(4, handle)).build(handle)
let mut connector = HttpConnector::new(4, handle);
if self.keep_alive {
connector.set_keepalive(self.keep_alive_timeout);
}
self.connector(connector).build(handle)
}
}