Auto merge of #19350 - gterzian:ignore_aborted_responses_in_caching, r=jdm

Ignore aborted responses in caching

<!-- Please describe your changes on the following line: -->
@jdm @KiChjang @Manishearth Follow up on https://github.com/servo/servo/pull/18676 and https://github.com/servo/servo/pull/19274 to ignore aborted responses in caching.

I also found out the cache shouldn't return any response whose body is still in `ResponseBody::Receiving` mode, because that fails the assertion at https://github.com/servo/servo/blob/master/components/net/fetch/methods.rs#L438(we might want to add a channel as pat of the cached response later on to deal with this case). I only found out now because I needed the response from the server to trickle in so that it could be cached and aborted.

I copied the `http-cache.py` server from the wpt folder, and added a 'trickle' option, which is necessary to actually have a failing test with a cached but aborted request, it's now passing.

I also remove one unused import that slippled through previously.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/19350)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-01-23 14:47:16 -06:00 committed by GitHub
commit 4307b6e67b
9 changed files with 236 additions and 25 deletions

View file

@ -10,6 +10,7 @@ use hyper::status::StatusCode;
use hyper_serde::Serde;
use servo_url::ServoUrl;
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
/// [Response type](https://fetch.spec.whatwg.org/#concept-response-type)
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
@ -113,7 +114,8 @@ pub struct Response {
/// whether or not to try to return the internal_response when asked for actual_response
pub return_internal: bool,
/// https://fetch.spec.whatwg.org/#concept-response-aborted
pub aborted: bool,
#[ignore_malloc_size_of = "AtomicBool heap size undefined"]
pub aborted: Arc<AtomicBool>,
}
impl Response {
@ -135,7 +137,7 @@ impl Response {
location_url: None,
internal_response: None,
return_internal: true,
aborted: false,
aborted: Arc::new(AtomicBool::new(false)),
}
}
@ -165,7 +167,7 @@ impl Response {
location_url: None,
internal_response: None,
return_internal: true,
aborted: false,
aborted: Arc::new(AtomicBool::new(false)),
}
}