fix: Upgrade to http2 if the server reports that it supports it (#1166)
The test is disabled as the test server does not support TLS currently but otherwise I'd expect it to pass (tested in another project).
This commit is contained in:
committed by
GitHub
parent
ad21b62fd2
commit
2940740493
@@ -370,17 +370,21 @@ impl Connector {
|
||||
let mut http = hyper_rustls::HttpsConnector::from((http, tls.clone()));
|
||||
let io = http.call(dst).await?;
|
||||
|
||||
if let hyper_rustls::MaybeHttpsStream::Https(stream) = &io {
|
||||
if let hyper_rustls::MaybeHttpsStream::Https(stream) = io {
|
||||
if !self.nodelay {
|
||||
let (io, _) = stream.get_ref();
|
||||
io.set_nodelay(false)?;
|
||||
}
|
||||
Ok(Conn {
|
||||
inner: self.verbose.wrap(RustlsTlsConn { inner: stream }),
|
||||
is_proxy,
|
||||
})
|
||||
} else {
|
||||
Ok(Conn {
|
||||
inner: self.verbose.wrap(io),
|
||||
is_proxy,
|
||||
})
|
||||
}
|
||||
|
||||
Ok(Conn {
|
||||
inner: self.verbose.wrap(io),
|
||||
is_proxy,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,27 @@ fn use_preconfigured_rustls_default() {
|
||||
.expect("preconfigured rustls tls");
|
||||
}
|
||||
|
||||
#[cfg(feature = "__rustls")]
|
||||
#[tokio::test]
|
||||
#[ignore = "Needs TLS support in the test server"]
|
||||
async fn http2_upgrade() {
|
||||
let server = server::http(move |_| async move { http::Response::default() });
|
||||
|
||||
let url = format!("https://localhost:{}", server.addr().port());
|
||||
let res = reqwest::Client::builder()
|
||||
.danger_accept_invalid_certs(true)
|
||||
.use_rustls_tls()
|
||||
.build()
|
||||
.expect("client builder")
|
||||
.get(&url)
|
||||
.send()
|
||||
.await
|
||||
.expect("request");
|
||||
|
||||
assert_eq!(res.status(), reqwest::StatusCode::OK);
|
||||
assert_eq!(res.version(), reqwest::Version::HTTP_2);
|
||||
}
|
||||
|
||||
#[cfg(feature = "default-tls")]
|
||||
#[tokio::test]
|
||||
async fn test_allowed_methods() {
|
||||
|
||||
Reference in New Issue
Block a user