Skip to content

Commit e5472e0

Browse files
author
Markus Westerlind
committed
fix: Only report http2 support if the http2 feature is enabled
Fixes rustls#143
1 parent 3f16ac4 commit e5472e0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ futures-util = { version = "0.3.1", default-features = false }
2828

2929
[features]
3030
default = ["native-tokio"]
31+
http2 = ["hyper/http2"]
3132
webpki-tokio = ["tokio-runtime", "webpki-roots"]
3233
native-tokio = ["tokio-runtime", "rustls-native-certs"]
3334
tokio-runtime = ["hyper/runtime", "ct-logs"]

src/connector.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ impl HttpsConnector<HttpConnector> {
6161
let mut http = HttpConnector::new();
6262
http.enforce_http(false);
6363

64-
config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
64+
#[cfg(feature = "http2")]
65+
{
66+
config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
67+
}
68+
#[cfg(not(feature = "http2"))]
69+
{
70+
config.alpn_protocols = vec![b"http/1.1".to_vec()];
71+
}
72+
6573
config.ct_logs = Some(&ct_logs::LOGS);
6674
(http, config).into()
6775
}

0 commit comments

Comments
 (0)