fix: respect https_only option when redirecting (#1313)

This commit is contained in:
David Leslie
2021-08-03 01:50:15 +02:00
committed by GitHub
parent e6a1a09f09
commit bdc57beabb
2 changed files with 36 additions and 1 deletions

View File

@@ -1634,8 +1634,15 @@ impl Future for PendingRequest {
match action {
redirect::ActionKind::Follow => {
debug!("redirecting '{}' to '{}'", self.url, loc);
self.url = loc;
if self.client.https_only && loc.scheme() != "https" {
return Poll::Ready(Err(error::redirect(
error::url_bad_scheme(loc.clone()),
loc,
)));
}
self.url = loc;
let mut headers =
std::mem::replace(self.as_mut().headers(), HeaderMap::new());