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"] async = ["futures-util", "async-stream", "reqwest/stream"]
websockets = ["tokio", "tokio-tungstenite"] websockets = ["tokio", "tokio-tungstenite"]
blocking = ["reqwest/blocking"] blocking = ["reqwest/blocking"]
follow-trusted = []
debug = [] debug = []
[lib] [lib]

View File

@ -150,7 +150,15 @@ impl ClientBuilder {
attempt.error("Too many redirects.") attempt.error("Too many redirects.")
} else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts_.contains(host) ) } 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 { } else {
let message = format!( let message = format!(
"Aborting redirect request to unknown host '{}'.", "Aborting redirect request to unknown host '{}'.",
@ -328,7 +336,15 @@ impl Client {
attempt.error("Too many redirects.") attempt.error("Too many redirects.")
} else if matches!( attempt.url().host_str(), Some(host) if trusted_hosts.contains(host) ) } 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 { } else {
let message = format!( let message = format!(
"Aborting redirect request to unknown host '{}'.", "Aborting redirect request to unknown host '{}'.",