From da171ca7033734b94d1d7a1659251ab28bb36cd3 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 9 May 2022 14:36:54 +0200 Subject: [PATCH] Add ConnectorBuilder::enable_all_versions() helper --- src/connector/builder.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/connector/builder.rs b/src/connector/builder.rs index a73d67c..c2d261c 100644 --- a/src/connector/builder.rs +++ b/src/connector/builder.rs @@ -174,6 +174,19 @@ impl ConnectorBuilder { }) } + /// Enable all HTTP versions + /// + /// For now, this enables both HTTP 1 and 2. In the future, other supported versions + /// will be enabled as well. + #[cfg(all(feature = "http1", feature = "http2"))] + pub fn enable_all_versions(mut self) -> ConnectorBuilder { + self.0.tls_config.alpn_protocols = vec![b"h2".to_vec()]; + ConnectorBuilder(WantsProtocols3 { + inner: self.0, + enable_http1: true, + }) + } + /// Override server name for the TLS stack /// /// By default, for each connection hyper-rustls will extract host portion