aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/http_cache.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-10-07 11:28:53 -0400
committerGitHub <noreply@github.com>2019-10-07 11:28:53 -0400
commit37ab273c826eb8b74882362db4584657fb448bb5 (patch)
treeac42d9555a836c011a63566ae86b22f39717bce6 /components/net/http_cache.rs
parent4c76b7a758e6ca6c67452cb3f9747c2be3ccf702 (diff)
parentb282ed9104adfba4f32f3337482786085a1633ac (diff)
downloadservo-37ab273c826eb8b74882362db4584657fb448bb5.tar.gz
servo-37ab273c826eb8b74882362db4584657fb448bb5.zip
Auto merge of #24370 - jdm:cache-crossorigin-test, r=gterzian
Cache crossorigin test This adds a test for #24356 to ensure that we don't regress our cache behaviour. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- 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/24370) <!-- Reviewable:end -->
Diffstat (limited to 'components/net/http_cache.rs')
-rw-r--r--components/net/http_cache.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs
index 9654c64acfa..43f82824b1d 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<CachedResponse> {
// TODO: generate warning headers as appropriate <https://tools.ietf.org/html/rfc7234#section-5.5>
+ 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);
@@ -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::<Vary>() {
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
}