mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Allow for redirects after a CORS-preflight
This commit is contained in:
parent
c584f3967c
commit
469eb192c5
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 {
|
||||
|
|
17
tests/wpt/metadata/cors/redirect-preflight.htm.ini
Normal file
17
tests/wpt/metadata/cors/redirect-preflight.htm.ini
Normal file
|
@ -0,0 +1,17 @@
|
|||
[redirect-preflight.htm]
|
||||
type: testharness
|
||||
[Disallow redirect 301 after succesful (200) preflight]
|
||||
expected: FAIL
|
||||
|
||||
[Disallow redirect 302 after succesful (200) preflight]
|
||||
expected: FAIL
|
||||
|
||||
[Disallow redirect 303 after succesful (200) preflight]
|
||||
expected: FAIL
|
||||
|
||||
[Disallow redirect 307 after succesful (200) preflight]
|
||||
expected: FAIL
|
||||
|
||||
[Disallow redirect 308 after succesful (200) preflight]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[redirect-userinfo.htm]
|
||||
type: testharness
|
||||
[Allow redirect with userinfo (//@)]
|
||||
expected: FAIL
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
[eventsource-cross-origin.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[EventSource: cross-origin redirect use]
|
||||
expected: TIMEOUT
|
||||
|
||||
[EventSource: cross-origin allow-origin: http://example.org should fail]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
|
||||
[Check referrerPolicy init value of same-origin and associated getter]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
type: testharness
|
||||
[Request has arrayBuffer method]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
prefs: [layout.viewport.enabled:true]
|
||||
[viewport_meta.html]
|
||||
type: reftest
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
prefs: [layout.viewport.enabled:true]
|
||||
[viewport_rule.html]
|
||||
type: reftest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue