mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Introduce http_loader::is_redirect_status
This commit is contained in:
parent
d64aa9c5bf
commit
e2e2d42e38
1 changed files with 13 additions and 5 deletions
|
@ -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 => {
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue