diff --git a/Cargo.toml b/Cargo.toml index f6d219e54..91706a994 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,8 @@ futures = "0.1.23" http = "0.1.15" hyper = "0.12.22" hyper-old-types = { version = "0.11", optional = true, features = ["compat"] } -hyper-tls = { version = "0.3", optional = true } flate2 = { version = "^1.0.7", default-features = false, features = ["rust_backend"] } +hyper-tls = { version = "0.3.2", optional = true } log = "0.4" mime = "0.3.7" mime_guess = "2.0.0-alpha.6" diff --git a/src/connect.rs b/src/connect.rs index f34ec339d..92423d3ac 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -174,9 +174,20 @@ impl Connect for Connector { #[cfg(feature = "default-tls")] Inner::DefaultTls(http, tls) => { let mut http = http.clone(); - http.set_nodelay(nodelay); + + http.set_nodelay(nodelay || ($dst.scheme() == "https")); + let http = ::hyper_tls::HttpsConnector::from((http, tls.clone())); - connect!(http, $dst, $proxy) + timeout!(http.connect($dst) + .and_then(move |(io, connected)| { + if let ::hyper_tls::MaybeHttpsStream::Https(stream) = &io { + if !nodelay { + stream.get_ref().get_ref().set_nodelay(false)?; + } + } + + Ok((Box::new(io) as Conn, connected.proxy($proxy))) + })) }, #[cfg(feature = "rustls-tls")] Inner::RustlsTls { http, tls, .. } => { @@ -191,9 +202,8 @@ impl Connect for Connector { timeout!(http.connect($dst) .and_then(move |(io, connected)| { if let ::hyper_rustls::MaybeHttpsStream::Https(stream) = &io { - let (io, _) = stream.get_ref(); - if !nodelay { + let (io, _) = stream.get_ref(); io.set_nodelay(false)?; } }