From 7a5df2126081b83d29758ef31f9f38369ac85ae4 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Wed, 20 Mar 2024 22:02:00 +0100 Subject: [PATCH] fix: could panic if http2 disabled but TLS negotiated h2 (#2194) The fix is only ask for h2 ALPN iff the http2 feature is enabled. Closes #2192 --- src/async_impl/client.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 926e21e59..a64869582 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -590,7 +590,11 @@ impl ClientBuilder { tls.alpn_protocols = vec!["h3".into()]; } HttpVersionPref::All => { - tls.alpn_protocols = vec!["h2".into(), "http/1.1".into()]; + tls.alpn_protocols = vec![ + #[cfg(feature = "http2")] + "h2".into(), + "http/1.1".into(), + ]; } }