Skip to content

Commit

Permalink
disable Nagle's for default-tls handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
quininer authored and seanmonstar committed Mar 20, 2019
1 parent 4764017 commit f02ca0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 14 additions & 4 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. } => {
Expand All @@ -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)?;
}
}
Expand Down

0 comments on commit f02ca0d

Please sign in to comment.