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:
Markus Westerlind
2021-02-10 22:16:22 +01:00
committed by GitHub
parent ad21b62fd2
commit 2940740493
2 changed files with 31 additions and 6 deletions

View File

@@ -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() {