Fix cfg for test
Fix up cfg attributes to work on an xor basis. Previously, the cfg(any()) attributes would cause issues when both native-tls and tls features were enabled. Now, https functions and enum variants will only be created when tls xor native-tls are enabled. Additionally, a compile error has been added for when both tls and native-tls features are enabled.
This commit is contained in:
11
src/unit.rs
11
src/unit.rs
@@ -10,7 +10,12 @@ use cookie::{Cookie, CookieJar};
|
||||
use crate::agent::AgentState;
|
||||
use crate::body::{self, Payload, SizedReader};
|
||||
use crate::header;
|
||||
use crate::stream::{self, connect_https, connect_test, Stream};
|
||||
#[cfg(any(
|
||||
all(feature = "tls", not(feature = "native-tls")),
|
||||
all(feature = "native-tls", not(feature = "tls")),
|
||||
))]
|
||||
use crate::stream::connect_https;
|
||||
use crate::stream::{self, connect_test, Stream};
|
||||
use crate::Proxy;
|
||||
use crate::{Error, Header, Request, Response};
|
||||
|
||||
@@ -286,6 +291,10 @@ fn connect_socket(unit: &Unit, use_pooled: bool) -> Result<(Stream, bool), Error
|
||||
}
|
||||
let stream = match unit.url.scheme() {
|
||||
"http" => stream::connect_http(&unit),
|
||||
#[cfg(any(
|
||||
all(feature = "tls", not(feature = "native-tls")),
|
||||
all(feature = "native-tls", not(feature = "tls")),
|
||||
))]
|
||||
"https" => connect_https(&unit),
|
||||
"test" => connect_test(&unit),
|
||||
_ => Err(Error::UnknownScheme(unit.url.scheme().to_string())),
|
||||
|
||||
Reference in New Issue
Block a user