From b347cf877c219a17cca2cb9ebbca47f809d25cb2 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 4 Oct 2019 15:26:03 -0400 Subject: [PATCH 1/2] Add some useful HTTP cache debug output. --- components/net/http_cache.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs index 4f751405d75..d20a1cd1279 100644 --- a/components/net/http_cache.rs +++ b/components/net/http_cache.rs @@ -297,6 +297,7 @@ fn create_cached_response( cached_headers: &HeaderMap, done_chan: &mut DoneChannel, ) -> CachedResponse { + debug!("creating a cached response for {:?}", request.url()); let resource_timing = ResourceFetchTiming::new(request.timing_type()); let mut response = Response::new( cached_resource.data.metadata.data.final_url.clone(), @@ -305,6 +306,7 @@ fn create_cached_response( response.headers = cached_headers.clone(); response.body = cached_resource.body.clone(); if let ResponseBody::Receiving(_) = *cached_resource.body.lock().unwrap() { + debug!("existing body is in progress"); let (done_sender, done_receiver) = unbounded(); *done_chan = Some((done_sender.clone(), done_receiver)); cached_resource @@ -571,8 +573,10 @@ impl HttpCache { done_chan: &mut DoneChannel, ) -> Option { // TODO: generate warning headers as appropriate + debug!("trying to construct cache response for {:?}", request.url()); if request.method != Method::GET { // Only Get requests are cached, avoid a url based match for others. + debug!("non-GET method, not caching"); return None; } let entry_key = CacheKey::new(request.clone()); @@ -588,6 +592,7 @@ impl HttpCache { let original_request_headers = cached_resource.request_headers.lock().unwrap(); if let Some(vary_value) = cached_headers.typed_get::() { if vary_value.is_any() { + debug!("vary value is any, not caching"); can_be_constructed = false } else { // For every header name found in the Vary header of the stored response. @@ -602,6 +607,7 @@ impl HttpCache { // Check that the value of the nominated header field, // in the original request, matches the value in the current request. if original_header_data != header_data { + debug!("headers don't match, not caching"); can_be_constructed = false; break; } @@ -613,6 +619,9 @@ impl HttpCache { // were also absent in the original request. can_be_constructed = original_request_headers.get(vary_val).is_none(); + if !can_be_constructed { + debug!("vary header present, not caching"); + } }, } if !can_be_constructed { @@ -663,6 +672,7 @@ impl HttpCache { return Some(cached_response); } } + debug!("couldn't find an appropriate response, not caching"); // The cache wasn't able to construct anything. None } From b282ed9104adfba4f32f3337482786085a1633ac Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 4 Oct 2019 15:27:20 -0400 Subject: [PATCH 2/2] Add test for filtered crossorigin cache response (#24356). --- tests/wpt/mozilla/meta/MANIFEST.json | 10 ++++++ .../cache_crossorigin_response.sub.html | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/wpt/mozilla/tests/mozilla/cache_crossorigin_response.sub.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 8197e544c91..6274543554e 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -11353,6 +11353,12 @@ {} ] ], + "mozilla/cache_crossorigin_response.sub.html": [ + [ + "mozilla/cache_crossorigin_response.sub.html", + {} + ] + ], "mozilla/calc.html": [ [ "mozilla/calc.html", @@ -18479,6 +18485,10 @@ "13a1a0fdc15ac05458ebf2c1fd75d501a6de92e3", "testharness" ], + "mozilla/cache_crossorigin_response.sub.html": [ + "266995f30afa3e9b3472e4cc43be6493c562aef6", + "testharness" + ], "mozilla/calc.html": [ "80aa06e2ae7cd5db585873f147a21382b279b86e", "testharness" diff --git a/tests/wpt/mozilla/tests/mozilla/cache_crossorigin_response.sub.html b/tests/wpt/mozilla/tests/mozilla/cache_crossorigin_response.sub.html new file mode 100644 index 00000000000..266995f30af --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/cache_crossorigin_response.sub.html @@ -0,0 +1,31 @@ + + +