mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #15889 - ferjm:issue-14519-cors-preflight, r=avadacatavra
Allow for redirects after a CORS-preflight ~Continue the work done in #14811 and #15547~. And applies the Fetch [spec change](0d9a4db8bc
) about [allowing redirects after CORS preflights](https://github.com/whatwg/fetch/issues/204). - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix ~#14787 and~ #14519 - [X] There are tests for these changes. Several WPTs go from FAIL to SUCCESS. The new expected FAILs for the cors/redirect-preflight.htm tests are caused by the spec change done [here](0d9a4db8bc
), as suggested in the associated [issue](https://github.com/servo/servo/issues/14519#issuecomment-284384667). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15889) <!-- Reviewable:end -->
This commit is contained in:
commit
c90d3d2f06
9 changed files with 25 additions and 16 deletions
|
@ -17,7 +17,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel};
|
|||
use hyper::status::StatusCode;
|
||||
use mime_guess::guess_mime_type;
|
||||
use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy};
|
||||
use net_traits::request::{RedirectMode, Referrer, Request, RequestMode, ResponseTainting};
|
||||
use net_traits::request::{Referrer, Request, RequestMode, ResponseTainting};
|
||||
use net_traits::request::{Type, Origin, Window};
|
||||
use net_traits::response::{Response, ResponseBody, ResponseType};
|
||||
use std::borrow::Cow;
|
||||
|
@ -240,7 +240,6 @@ pub fn main_fetch(request: Rc<Request>,
|
|||
(!is_simple_method(&request.method.borrow()) ||
|
||||
request.headers.borrow().iter().any(|h| !is_simple_header(&h)))) {
|
||||
request.response_tainting.set(ResponseTainting::CorsTainting);
|
||||
request.redirect_mode.set(RedirectMode::Error);
|
||||
let response = http_fetch(request.clone(), cache, true, true, false,
|
||||
target, done_chan, context);
|
||||
if response.is_network_error() {
|
||||
|
|
|
@ -746,11 +746,7 @@ fn http_redirect_fetch(request: Rc<Request>,
|
|||
request.redirect_count.set(request.redirect_count.get() + 1);
|
||||
|
||||
// Step 7
|
||||
let same_origin = if let Origin::Origin(ref origin) = *request.origin.borrow() {
|
||||
*origin == request.current_url().origin()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let same_origin = location_url.origin()== request.current_url().origin();
|
||||
let has_credentials = has_credentials(&location_url);
|
||||
|
||||
if request.mode == RequestMode::CorsMode && !same_origin && has_credentials {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue