Moved follow-trusted as a feature.

main
Mauro D 2022-09-09 10:27:03 +00:00
parent 15624137be
commit 24c5e61cf3
2 changed files with 19 additions and 2 deletions

View File

@ -29,6 +29,7 @@ default = ["async"]
async = ["futures-util", "async-stream", "reqwest/stream"]
websockets = ["tokio", "tokio-tungstenite"]
blocking = ["reqwest/blocking"]
follow-trusted = []
debug = []
[lib]

View File

@ -149,8 +149,16 @@ impl ClientBuilder {
if attempt.previous().len() > 5 {
attempt.error("Too many redirects.")
} else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts_.contains(host) )
{
#[cfg(feature = "follow-trusted")]
{
attempt.follow_trusted()
}
#[cfg(not(feature = "follow-trusted"))]
{
attempt.follow()
}
} else {
let message = format!(
"Aborting redirect request to unknown host '{}'.",
@ -327,8 +335,16 @@ impl Client {
if attempt.previous().len() > 5 {
attempt.error("Too many redirects.")
} else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts.contains(host) )
{
#[cfg(feature = "follow-trusted")]
{
attempt.follow_trusted()
}
#[cfg(not(feature = "follow-trusted"))]
{
attempt.follow()
}
} else {
let message = format!(
"Aborting redirect request to unknown host '{}'.",