only follow up to 6 redirects in default reqwest ClientBuilder

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-01-13 18:09:37 -05:00 committed by June
parent ae11e378d2
commit da539efb98

View file

@ -539,10 +539,19 @@ impl Service<'_> {
}
fn reqwest_client_builder(config: &Config) -> Result<reqwest::ClientBuilder> {
let redirect_policy = reqwest::redirect::Policy::custom(|attempt| {
if attempt.previous().len() > 6 {
attempt.error("Too many redirects (max is 6)")
} else {
attempt.follow()
}
});
let mut reqwest_client_builder = reqwest::Client::builder()
.pool_max_idle_per_host(0)
.connect_timeout(Duration::from_secs(60))
.timeout(Duration::from_secs(60 * 5))
.redirect(redirect_policy)
.user_agent(concat!(
env!("CARGO_PKG_NAME"),
"/",