Skip to content

Commit

Permalink
servo: Merge #15889 - Allow for redirects after a CORS-preflight (fro…
Browse files Browse the repository at this point in the history
…m ferjm:issue-14519-cors-preflight); r=avadacatavra

~Continue the work done in #14811 and #15547~. And applies the Fetch [spec change](whatwg/fetch@0d9a4db) about [allowing redirects after CORS preflights](whatwg/fetch#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](whatwg/fetch@0d9a4db), as suggested in the associated [issue](servo/servo#14519 (comment)).

Source-Repo: https://github.com/servo/servo
Source-Revision: c90d3d2f06c03d153b2be3ffa9a941cbfe8508cc

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 8a0dde32f10f530604eec26929466f886c6cd610
  • Loading branch information
ferjm committed Mar 10, 2017
1 parent a826dac commit b8c29ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions servo/components/net/fetch/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions servo/components/net/http_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b8c29ac

Please sign in to comment.