Skip to content

Commit

Permalink
Introduce http_loader::is_redirect_status
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Mar 27, 2017
1 parent d64aa9c commit e2e2d42
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions components/net/http_loader.rs
Expand Up @@ -629,11 +629,7 @@ pub fn http_fetch(request: Rc<Request>,
// 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 => {
Expand Down Expand Up @@ -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,
}
}

0 comments on commit e2e2d42

Please sign in to comment.