Skip to content

Commit 406b59e

Browse files
authored
fix http2 feature is not enabled for native-tls ALPN (#2927)
1 parent 325a020 commit 406b59e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/async_impl/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,11 @@ impl ClientBuilder {
531531
tls.request_alpns(&["h2"]);
532532
}
533533
HttpVersionPref::All => {
534-
tls.request_alpns(&["h2", "http/1.1"]);
534+
tls.request_alpns(&[
535+
#[cfg(feature = "http2")]
536+
"h2",
537+
"http/1.1",
538+
]);
535539
}
536540
}
537541
}

tests/client.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,21 @@ fn use_preconfigured_rustls_default() {
371371
.expect("preconfigured rustls tls");
372372
}
373373

374+
#[cfg(all(feature = "__tls", not(any(feature = "http2", feature = "http3")),))]
375+
#[tokio::test]
376+
async fn http1_only() {
377+
let res = reqwest::Client::builder()
378+
.build()
379+
.expect("client builder")
380+
.get("https://google.com")
381+
.send()
382+
.await
383+
.expect("request");
384+
385+
assert_eq!(res.status(), reqwest::StatusCode::OK);
386+
assert_eq!(res.version(), reqwest::Version::HTTP_11);
387+
}
388+
374389
#[cfg(feature = "__rustls")]
375390
#[tokio::test]
376391
#[ignore = "Needs TLS support in the test server"]

0 commit comments

Comments
 (0)