From db1e1aaec17e64b1386ea8e3ce4aade336c0633c Mon Sep 17 00:00:00 2001 From: Martin Algesten Date: Sat, 27 Jul 2024 22:18:36 +0200 Subject: [PATCH] Fix broken compilation --- src/agent.rs | 1 + src/config.rs | 16 +++++++++++----- src/tls/mod.rs | 2 +- src/transport/mod.rs | 7 +++---- src/util.rs | 2 ++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index 7992a7ed..99adcaa6 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -128,6 +128,7 @@ impl Agent { } else { Some(body.body_mode()) }; + #[cfg(any(feature = "gzip", feature = "brotli"))] let has_header_accept_enc = headers.has_accept_encoding(); let has_header_ua = headers.has_user_agent(); diff --git a/src/config.rs b/src/config.rs index 5b8062fb..10a68b13 100644 --- a/src/config.rs +++ b/src/config.rs @@ -219,8 +219,9 @@ impl Default for AgentConfig { impl fmt::Debug for AgentConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("AgentConfig") - .field("timeout_global", &self.timeout_global) + let mut dbg = f.debug_struct("AgentConfig"); + + dbg.field("timeout_global", &self.timeout_global) .field("timeout_per_call", &self.timeout_per_call) .field("timeout_resolve", &self.timeout_resolve) .field("timeout_connect", &self.timeout_connect) @@ -242,8 +243,13 @@ impl fmt::Debug for AgentConfig { &self.max_idle_connections_per_host, ) .field("max_idle_age", &self.max_idle_age) - .field("tls_config", &self.tls_config) - .field("proxy", &self.proxy) - .finish() + .field("proxy", &self.proxy); + + #[cfg(feature = "_tls")] + { + dbg.field("tls_config", &self.tls_config); + } + + dbg.finish() } } diff --git a/src/tls/mod.rs b/src/tls/mod.rs index 6bbc0124..ac8c668f 100644 --- a/src/tls/mod.rs +++ b/src/tls/mod.rs @@ -1,8 +1,8 @@ //! TLS for handling `https`. -mod cert; use std::sync::Arc; +mod cert; pub use cert::{parse_pem, Certificate, PemItem, PrivateKey}; #[cfg(feature = "rustls")] diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 38273202..1dbc7896 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -13,7 +13,7 @@ //! * TCP Sockets //! * SOCKS-proxy sockets //! * HTTPS/TLS using rustls (feature flag **rustls**) -//! * HTTPS/TLS using native-tls (feature flag **native-tls** + [config](TlsProvider::NativeTls)) +//! * HTTPS/TLS using native-tls (feature flag **native-tls** + [config](crate::tls::TlsProvider::NativeTls)) //! //! The [`Connector`] trait anticipates a chain of connectors that each decide //! whether to help perform the connection or not. It is for instance possible to make a @@ -27,7 +27,6 @@ use std::net::SocketAddr; use http::Uri; use crate::resolver::Resolver; -use crate::tls::TlsProvider; use crate::{AgentConfig, Error}; pub use self::tcp::TcpConnector; @@ -228,7 +227,7 @@ impl Default for DefaultConnector { // Panic if the config calls for rustls, the uri scheme is https and that // TLS provider is not enabled by feature flags. #[cfg(feature = "_tls")] - no_tls::WarnOnMissingTlsProvider(TlsProvider::RustlsWithRing).boxed(), + no_tls::WarnOnMissingTlsProvider(crate::tls::TlsProvider::RustlsWithRing).boxed(), // // As a fallback if rustls isn't enabled, use native-tls #[cfg(feature = "native-tls")] @@ -237,7 +236,7 @@ impl Default for DefaultConnector { // Panic if the config calls for native-tls, the uri scheme is https and that // TLS provider is not enabled by feature flags. #[cfg(feature = "_tls")] - no_tls::WarnOnMissingTlsProvider(TlsProvider::NativeTls).boxed(), + no_tls::WarnOnMissingTlsProvider(crate::tls::TlsProvider::NativeTls).boxed(), ]); DefaultConnector { chain } diff --git a/src/util.rs b/src/util.rs index 5dc03505..c28b26fa 100644 --- a/src/util.rs +++ b/src/util.rs @@ -297,6 +297,7 @@ pub(crate) trait HeaderMapExt { fn get_str(&self, k: &str) -> Option<&str>; fn is_chunked(&self) -> bool; fn content_length(&self) -> Option; + #[cfg(any(feature = "gzip", feature = "brotli"))] fn has_accept_encoding(&self) -> bool; fn has_user_agent(&self) -> bool; fn has_send_body_mode(&self) -> bool { @@ -321,6 +322,7 @@ impl HeaderMapExt for HeaderMap { Some(len) } + #[cfg(any(feature = "gzip", feature = "brotli"))] fn has_accept_encoding(&self) -> bool { self.contains_key("accept-encoding") }