Only follow 307/308 redirects for methods without a body

This commit is contained in:
Joshua Nelson
2020-12-03 08:23:17 -05:00
committed by Martin Algesten
parent 8d21052c7e
commit 6bab430d29

View File

@@ -264,7 +264,9 @@ pub(crate) fn connect(
return connect(new_unit, use_pooled, redirect_count + 1, empty, true); return connect(new_unit, use_pooled, redirect_count + 1, empty, true);
} }
// never change the method for 307/308 // never change the method for 307/308
307 | 308 => { // only resend the request if it cannot have a body
// NOTE: DELETE is intentionally excluded: https://stackoverflow.com/questions/299628
307 | 308 if ["GET", "HEAD", "OPTIONS", "TRACE"].contains(&method.as_str()) => {
let empty = Payload::Empty.into_read(); let empty = Payload::Empty.into_read();
debug!("redirect {} {} -> {}", resp.status(), url, new_url); debug!("redirect {} {} -> {}", resp.status(), url, new_url);
return connect(unit, use_pooled, redirect_count - 1, empty, true); return connect(unit, use_pooled, redirect_count - 1, empty, true);