Strip request-body-header when redirecting from a POST to GET

This doesn't change any expectation because we're not setting
response.redirected properly so all the tests fail later on when it's
asserted to be true.

Fixes #25257
This commit is contained in:
Bastien Orivel 2019-12-21 13:40:39 +01:00
parent 6653b89b64
commit 566147dab3
2 changed files with 15 additions and 3 deletions

View file

@ -25,7 +25,10 @@ use headers::{
use headers::{AccessControlAllowOrigin, AccessControlMaxAge};
use headers::{CacheControl, ContentEncoding, ContentLength};
use headers::{IfModifiedSince, LastModified, Origin as HyperOrigin, Pragma, Referer, UserAgent};
use http::header::{self, HeaderName, HeaderValue};
use http::header::{
self, HeaderName, HeaderValue, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LOCATION,
CONTENT_TYPE,
};
use http::{HeaderMap, Request as HyperRequest};
use hyper::{Body, Client, Method, Response as HyperResponse, StatusCode};
use hyper_serde::Serde;
@ -804,8 +807,18 @@ pub fn http_redirect_fetch(
(*code == StatusCode::SEE_OTHER && request.method != Method::HEAD)
})
{
// Step 11.1
request.method = Method::GET;
request.body = None;
// Step 11.2
for name in &[
CONTENT_ENCODING,
CONTENT_LANGUAGE,
CONTENT_LOCATION,
CONTENT_TYPE,
] {
request.headers.remove(name);
}
}
// Step 12

View file

@ -287,8 +287,7 @@ impl ResponseMethods for Response {
// https://fetch.spec.whatwg.org/#dom-response-redirected
fn Redirected(&self) -> bool {
let url_list_len = self.url_list.borrow().len();
url_list_len > 1
return *self.redirected.borrow();
}
// https://fetch.spec.whatwg.org/#dom-response-status