From 199f6af1e1ffcab298784dfe4f752f041fa7825b Mon Sep 17 00:00:00 2001 From: Thiago Arrais Date: Mon, 30 Nov 2020 13:27:18 -0300 Subject: [PATCH] supports origin-relative redirects --- awc/src/connect.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/awc/src/connect.rs b/awc/src/connect.rs index 2576ccf1e..810864891 100644 --- a/awc/src/connect.rs +++ b/awc/src/connect.rs @@ -118,6 +118,7 @@ where Body::Message(_) => Body::Empty, }; + let uri = head.uri.clone(); let mut reqhead = RequestHead::default(); reqhead.method = head.method.clone(); reqhead.version = head.version.clone(); @@ -144,7 +145,12 @@ where reqhead.method = actix_http::http::Method::GET; reqbody = Body::None; } - reqhead.uri = location_uri; + let mut parts = location_uri.clone().into_parts(); + if location_uri.authority().is_none() { + parts.scheme = Some(uri.scheme().unwrap().clone()); + parts.authority = Some(uri.authority().unwrap().clone()); + } + reqhead.uri = Uri::from_parts(parts).unwrap(); return deal_with_redirects( backend.clone(), reqhead,