From 6bab430d2903414bac4f01e66df1ed568f049f1e Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 3 Dec 2020 08:23:17 -0500 Subject: [PATCH] Only follow 307/308 redirects for methods without a body --- src/unit.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unit.rs b/src/unit.rs index f39bd3b..4f794de 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -264,7 +264,9 @@ pub(crate) fn connect( return connect(new_unit, use_pooled, redirect_count + 1, empty, true); } // 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(); debug!("redirect {} {} -> {}", resp.status(), url, new_url); return connect(unit, use_pooled, redirect_count - 1, empty, true);