supports origin-relative redirects

This commit is contained in:
Thiago Arrais 2020-11-30 13:27:18 -03:00
parent d16d1de93f
commit 199f6af1e1
1 changed files with 7 additions and 1 deletions

View File

@ -118,6 +118,7 @@ where
Body::Message(_) => Body::Empty, Body::Message(_) => Body::Empty,
}; };
let uri = head.uri.clone();
let mut reqhead = RequestHead::default(); let mut reqhead = RequestHead::default();
reqhead.method = head.method.clone(); reqhead.method = head.method.clone();
reqhead.version = head.version.clone(); reqhead.version = head.version.clone();
@ -144,7 +145,12 @@ where
reqhead.method = actix_http::http::Method::GET; reqhead.method = actix_http::http::Method::GET;
reqbody = Body::None; 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( return deal_with_redirects(
backend.clone(), backend.clone(),
reqhead, reqhead,