diff --git a/src/authenticator.rs b/src/authenticator.rs index d862aa286..0df1a2b40 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -746,6 +746,9 @@ pub trait HyperClientBuilder { /// Create a hyper::Client fn build_hyper_client(self) -> hyper::Client; + /// Create a `hyper::Client` (HTTPS not required) + fn build_insecure_http_hyper_client(self) -> hyper::Client; + /// Create a `hyper::Client` for tests (HTTPS not required) #[doc(hidden)] fn build_test_hyper_client(self) -> hyper::Client; @@ -789,6 +792,22 @@ impl HyperClientBuilder for DefaultHyperClient { type Connector = hyper_tls::HttpsConnector; fn build_hyper_client(self) -> hyper::Client { + #[cfg(feature = "hyper-rustls")] + let connector = hyper_rustls::HttpsConnectorBuilder::new() + .with_native_roots() + .https_only() + .enable_http1() + .enable_http2() + .build(); + #[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))] + let connector = hyper_tls::HttpsConnector::new(); + + hyper::Client::builder() + .pool_max_idle_per_host(0) + .build::<_, hyper::Body>(connector) + } + + fn build_insecure_http_hyper_client(self) -> hyper::Client { #[cfg(feature = "hyper-rustls")] let connector = hyper_rustls::HttpsConnectorBuilder::new() .with_native_roots() @@ -834,6 +853,10 @@ where self } + fn build_insecure_http_hyper_client(self) -> hyper::Client { + self + } + fn build_test_hyper_client(self) -> hyper::Client { self }