diff --git a/Cargo.toml b/Cargo.toml index db19a33..99dac8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ default = ["async"] async = ["futures-util", "async-stream", "reqwest/stream"] websockets = ["tokio", "tokio-tungstenite"] blocking = ["reqwest/blocking"] +follow-trusted = [] debug = [] [lib] diff --git a/src/client.rs b/src/client.rs index 147a0b1..1c1378c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -150,7 +150,15 @@ impl ClientBuilder { attempt.error("Too many redirects.") } else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts_.contains(host) ) { - attempt.follow_trusted() + #[cfg(feature = "follow-trusted")] + { + attempt.follow_trusted() + } + + #[cfg(not(feature = "follow-trusted"))] + { + attempt.follow() + } } else { let message = format!( "Aborting redirect request to unknown host '{}'.", @@ -328,7 +336,15 @@ impl Client { attempt.error("Too many redirects.") } else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts.contains(host) ) { - attempt.follow_trusted() + #[cfg(feature = "follow-trusted")] + { + attempt.follow_trusted() + } + + #[cfg(not(feature = "follow-trusted"))] + { + attempt.follow() + } } else { let message = format!( "Aborting redirect request to unknown host '{}'.",