From 24c5e61cf3a4b9ec0d3e706dd84c66c77902f3a0 Mon Sep 17 00:00:00 2001 From: Mauro D Date: Fri, 9 Sep 2022 10:27:03 +0000 Subject: [PATCH] Moved follow-trusted as a feature. --- Cargo.toml | 1 + src/client.rs | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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 '{}'.",