Auto merge of #18676 - gterzian:continue_http_cache_work, r=jdm

Continue http cache work

<!-- Please describe your changes on the following line: -->

Work in progress, and not quite worth a review yet. (Continuation of https://github.com/servo/servo/pull/4117)

TODO

- [ ] cache metadata (find some subset of`net_traits::Metadata` that can be shared across threads, it seems the problem is mainly stuff inside `hyper::header` in the `headers` field)

- [ ] determine which other fields of a `Response` need to be cached, so a full and valid one can be returned upon a cache hit.

- [ ] determine how to best share the cache across fetch threads (inside HttpState like I tried now?)

- [ ] Spend more time reading the spec and make sure the cache follows it where it matters.

- [ ] Make the current wpt tests pass.

- [ ] More...

---
<!-- 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 #12972  (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/18676)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-11-20 18:22:06 -06:00 committed by GitHub
commit e2bc0f017c
37 changed files with 1238 additions and 631 deletions

View file

@ -234,6 +234,12 @@ impl Headers {
*self.header_list.borrow_mut() = hyper_headers;
}
pub fn get_headers_list(&self) -> HyperHeaders {
let mut headers = HyperHeaders::new();
headers.extend(self.header_list.borrow_mut().iter());
headers
}
// https://fetch.spec.whatwg.org/#concept-header-extract-mime-type
pub fn extract_mime_type(&self) -> Vec<u8> {
self.header_list.borrow().get_raw("content-type").map_or(vec![], |v| v[0].clone())

View file

@ -339,6 +339,9 @@ impl Request {
_ => {},
}
// Copy the headers list onto the headers of net_traits::Request
r.request.borrow_mut().headers = r.Headers().get_headers_list();
// Step 32
let mut input_body = if let RequestInfo::Request(ref input_request) = input {
let input_request_request = input_request.request.borrow();
@ -459,17 +462,7 @@ fn normalize_method(m: &str) -> HttpMethod {
// https://fetch.spec.whatwg.org/#concept-method
fn is_method(m: &ByteString) -> bool {
match m.to_lower().as_str() {
Some("get") => true,
Some("head") => true,
Some("post") => true,
Some("put") => true,
Some("delete") => true,
Some("connect") => true,
Some("options") => true,
Some("trace") => true,
_ => false,
}
m.as_str().is_some()
}
// https://fetch.spec.whatwg.org/#forbidden-method