Skip to content

Commit 2c673c0

Browse files
MarwesMarkus Westerlind
andauthored
fix: Only report http2 support if the http2 feature is enabled (#144)
Co-authored-by: Markus Westerlind <[email protected]>
1 parent 3f16ac4 commit 2c673c0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ hyper = { version = "0.14", features = ["full"] }
2727
futures-util = { version = "0.3.1", default-features = false }
2828

2929
[features]
30-
default = ["native-tokio"]
30+
default = ["native-tokio", "http1"]
31+
http1 = ["hyper/http1"]
32+
http2 = ["hyper/http2"]
3133
webpki-tokio = ["tokio-runtime", "webpki-roots"]
3234
native-tokio = ["tokio-runtime", "rustls-native-certs"]
3335
tokio-runtime = ["hyper/runtime", "ct-logs"]

src/connector.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ 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+
config.alpn_protocols.clear();
65+
#[cfg(feature = "http2")]
66+
{
67+
config.alpn_protocols.push(b"h2".to_vec());
68+
}
69+
70+
#[cfg(feature = "http1")]
71+
{
72+
config.alpn_protocols.push(b"http/1.1".to_vec());
73+
}
74+
6575
config.ct_logs = Some(&ct_logs::LOGS);
6676
(http, config).into()
6777
}

0 commit comments

Comments
 (0)