From d16d1de93f4e8dbf3e9a26dde2ed92613e7bbcbb Mon Sep 17 00:00:00 2001 From: Thiago Arrais Date: Wed, 4 Nov 2020 13:33:44 -0300 Subject: [PATCH] Should not send body with GET request --- awc/src/connect.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/awc/src/connect.rs b/awc/src/connect.rs index 1a1b55d19..2576ccf1e 100644 --- a/awc/src/connect.rs +++ b/awc/src/connect.rs @@ -109,8 +109,7 @@ where Box::pin(async move { let connection = fut.await?; - // FIXME: whether we'll resend the body depends on the redirect status code - let reqbody = match body { + let mut reqbody = match body { Body::None => Body::None, Body::Empty => Body::Empty, Body::Bytes(ref b) => Body::Bytes(b.clone()), @@ -120,7 +119,6 @@ where }; let mut reqhead = RequestHead::default(); - // FIXME: method depends on redirect code reqhead.method = head.method.clone(); reqhead.version = head.version.clone(); // FIXME: not all headers should be mirrored on redirect @@ -142,6 +140,10 @@ where if let Ok(location_str) = location_value.to_str(); if let Ok(location_uri) = location_str.parse::(); then { + if resphead.status == actix_http::http::StatusCode::SEE_OTHER { + reqhead.method = actix_http::http::Method::GET; + reqbody = Body::None; + } reqhead.uri = location_uri; return deal_with_redirects( backend.clone(),