mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +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
|
// Step 5
|
||||||
match response.actual_response().status {
|
match response.actual_response().status {
|
||||||
// Code 301, 302, 303, 307, 308
|
// Code 301, 302, 303, 307, 308
|
||||||
Some(StatusCode::MovedPermanently) |
|
status if status.map_or(false, is_redirect_status) => {
|
||||||
Some(StatusCode::Found) |
|
|
||||||
Some(StatusCode::SeeOther) |
|
|
||||||
Some(StatusCode::TemporaryRedirect) |
|
|
||||||
Some(StatusCode::PermanentRedirect) => {
|
|
||||||
response = match request.redirect_mode.get() {
|
response = match request.redirect_mode.get() {
|
||||||
RedirectMode::Error => Response::network_error(NetworkError::Internal("Redirect mode error".into())),
|
RedirectMode::Error => Response::network_error(NetworkError::Internal("Redirect mode error".into())),
|
||||||
RedirectMode::Manual => {
|
RedirectMode::Manual => {
|
||||||
|
@ -1418,3 +1414,15 @@ fn response_needs_revalidation(_response: &Response) -> bool {
|
||||||
// TODO this function
|
// TODO this function
|
||||||
false
|
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