diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index ca972034471..f4ee1da4251 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -629,11 +629,7 @@ pub fn http_fetch(request: Rc, // Step 5 match response.actual_response().status { // Code 301, 302, 303, 307, 308 - Some(StatusCode::MovedPermanently) | - Some(StatusCode::Found) | - Some(StatusCode::SeeOther) | - Some(StatusCode::TemporaryRedirect) | - Some(StatusCode::PermanentRedirect) => { + status if status.map_or(false, is_redirect_status) => { response = match request.redirect_mode.get() { RedirectMode::Error => Response::network_error(NetworkError::Internal("Redirect mode error".into())), RedirectMode::Manual => { @@ -1418,3 +1414,15 @@ fn response_needs_revalidation(_response: &Response) -> bool { // TODO this function false } + +/// https://fetch.spec.whatwg.org/#redirect-status +fn is_redirect_status(status: StatusCode) -> bool { + match status { + StatusCode::MovedPermanently | + StatusCode::Found | + StatusCode::SeeOther | + StatusCode::TemporaryRedirect | + StatusCode::PermanentRedirect => true, + _ => false, + } +}