Skip to content

Commit

Permalink
Initiate redirect fetching iff the request has a location
Browse files Browse the repository at this point in the history
Without this checking, we will run into a TIMEOUT request because
http_redirect_fetch will return immediately when location doesn't exist.
  • Loading branch information
CYBAI committed May 9, 2020
1 parent 033156b commit b4089bc
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 8 deletions.
20 changes: 15 additions & 5 deletions components/constellation/network_listener.rs
Expand Up @@ -7,7 +7,7 @@
//! response is received, it is forwarded to the appropriate script thread.

use crossbeam_channel::Sender;
use http::header::LOCATION;
use http::HeaderMap;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use msg::constellation_msg::PipelineId;
Expand Down Expand Up @@ -98,8 +98,12 @@ impl NetworkListener {
FetchMetadata::Unfiltered(ref m) => m,
};

match metadata.headers {
Some(ref headers) if headers.contains_key(LOCATION) => {
match metadata.location_url {
// https://html.spec.whatwg.org/multipage/#process-a-navigate-fetch
// Step 7-4.
Some(Ok(ref location_url))
if matches!(location_url.scheme(), "http" | "https") =>
{
if self.request_builder.url_list.is_empty() {
self.request_builder
.url_list
Expand All @@ -115,10 +119,16 @@ impl NetworkListener {
.map(|referrer_url| Referrer::ReferrerUrl(referrer_url));
self.request_builder.referrer_policy = metadata.referrer_policy;

let headers = if let Some(ref headers) = metadata.headers {
headers.clone().into_inner()
} else {
HeaderMap::new()
};

self.res_init = Some(ResponseInit {
url: metadata.final_url.clone(),
location_url: metadata.location_url.clone(),
headers: headers.clone().into_inner(),
headers,
referrer: metadata.referrer.clone(),
status_code: metadata
.status
Expand All @@ -132,7 +142,7 @@ impl NetworkListener {
//
// Ideally the Fetch code would handle manual redirects on its own
self.initiate_fetch(None);
},
}
_ => {
// Response should be processed by script thread.
self.should_send = true;
Expand Down
67 changes: 66 additions & 1 deletion tests/wpt/metadata/cookies/http-state/domain-tests.html.ini
@@ -1,2 +1,67 @@
[domain-tests.html]
expected: TIMEOUT
[domain0036 - domain0036]
expected: FAIL

[domain0035 - domain0035]
expected: FAIL

[domain0029 - domain0029]
expected: FAIL

[domain0022 - domain0022]
expected: FAIL

[domain0005 - domain0005]
expected: FAIL

[optional-domain0041 - optional-domain0041]
expected: FAIL

[domain0003 - domain0003]
expected: FAIL

[domain0019 - domain0019]
expected: FAIL

[domain0040 - domain0040]
expected: FAIL

[domain0025 - domain0025]
expected: FAIL

[domain0020 - domain0020]
expected: FAIL

[domain0001 - domain0001]
expected: FAIL

[domain0038 - domain0038]
expected: FAIL

[domain0039 - domain0039]
expected: FAIL

[domain0033 - domain0033]
expected: FAIL

[domain0031 - domain0031]
expected: FAIL

[domain0023 - domain0023]
expected: FAIL

[domain0012 - domain0012]
expected: FAIL

[domain0008 - domain0008]
expected: FAIL

[domain0009 - domain0009]
expected: FAIL

[domain0026 - domain0026]
expected: FAIL

[domain0004 - domain0004]
expected: FAIL

@@ -1,2 +1,4 @@
[ordering-tests.html]
expected: TIMEOUT
[ordering0001 - ordering0001]
expected: FAIL

40 changes: 39 additions & 1 deletion tests/wpt/metadata/cookies/http-state/path-tests.html.ini
@@ -1,2 +1,40 @@
[path-tests.html]
expected: TIMEOUT
[path0015 - path0015]
expected: FAIL

[path0002 - path0002]
expected: FAIL

[path0003 - path0003]
expected: FAIL

[path0004 - path0004]
expected: FAIL

[path0001 - path0001]
expected: FAIL

[path0016 - path0016]
expected: FAIL

[path0026 - path0026]
expected: FAIL

[path0017 - path0017]
expected: FAIL

[path0032 - path0032]
expected: FAIL

[path0029 - path0029]
expected: FAIL

[disabled-path0029 - disabled-path0029]
expected: FAIL

[path0010 - path0010]
expected: FAIL

[path0007 - path0007]
expected: FAIL

0 comments on commit b4089bc

Please sign in to comment.