Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement the Fetch method #13323
Implement the Fetch method #13323
Conversation
highfive
commented
Sep 19, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 19, 2016
|
r? @jdm |
c291b8e
to
c135549
|
@bors-servo: try |
|
|
Implement the Fetch method <!-- Please describe your changes on the following line: --> This PR implements the fetch method, which is described in [the Fetch Spec](https://fetch.spec.whatwg.org/#fetch-method). The expected wpt results are updated as well. A few comments about the current fetch implementation: - The fetch method manually calls `JSAutoCompartment` in order to prevent SpiderMonkey from crashing. This may have to change in the future. - Not all `FetchResponseListener` methods are implemented. - `net_traits::CoreResourceMsg::Fetch` message takes a `net_traits::request::RequestInit`. However, when the fetch method is called, a `RequestBinding::RequestInit` is given. The fetch method constructs a `dom::request::Request` with the given `RequestInit`, then creates `net_traits::request::RequestInit` from the dom Request object for the fetch message. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11898 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13323) <!-- Reviewable:end -->
|
|
|
Nice work! |
| @@ -217,6 +217,10 @@ impl Headers { | |||
| self.guard.set(new_guard) | |||
| } | |||
|
|
|||
| pub fn set_guard_immutable(&self) { | |||
This comment has been minimized.
This comment has been minimized.
|
|
||
| impl Response { | ||
| pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>) { | ||
| self.Headers().set_headers( match option_hyper_headers { |
This comment has been minimized.
This comment has been minimized.
| use std::sync::{Arc, Mutex}; | ||
| use url::Url; | ||
|
|
||
| #[allow(unrooted_must_root)] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jeenalee
Sep 21, 2016
•
Author
Contributor
The compiler was saying that that Fallible<Rc<Promise>> should be rooted, and that was the reason it was added. But looking at the code again, I don't think it's required. I'll try removing it.
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| fn from_referer_to_referer_url(request: &NetTraitsRequest) -> Option<Url> { | ||
| let referer = request.referrer.borrow(); |
This comment has been minimized.
This comment has been minimized.
| response_object: Trusted<Response>, | ||
| } | ||
|
|
||
| fn from_referer_to_referer_url(request: &NetTraitsRequest) -> Option<Url> { |
This comment has been minimized.
This comment has been minimized.
| [Exposed=(Window,Worker)] | ||
|
|
||
| partial interface WindowOrWorkerGlobalScope { | ||
| [NewObject, Throws] Promise<Response> fetch(RequestInfo input, optional RequestInit init); |
This comment has been minimized.
This comment has been minimized.
| let (action_sender, action_receiver) = ipc::channel().unwrap(); | ||
| let fetch_context = Arc::new(Mutex::new(FetchContext { | ||
| fetch_promise: Some(TrustedPromise::new(promise.clone())), | ||
| response_object: Trusted::new(response.r()), |
This comment has been minimized.
This comment has been minimized.
| })); | ||
| let listener = NetworkListener { | ||
| context: fetch_context.clone(), | ||
| // TODO: double check how to get script_chan |
This comment has been minimized.
This comment has been minimized.
| response_object: Trusted::new(response.r()), | ||
| })); | ||
| let listener = NetworkListener { | ||
| context: fetch_context.clone(), |
This comment has been minimized.
This comment has been minimized.
|
|
||
| #[allow(unrooted_must_root)] | ||
| fn process_response(&mut self, metadata: Result<Metadata, NetworkError>) { | ||
| let promise = match self.fetch_promise.take() { |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 21, 2016
Member
Let's use let promise = self.fetch_promise.take().expect("fetch promise is missing").root();
|
@jdm Review comments addressed! |
|
Great! You can squash your commits together, and then we'll merge this once #12830 is merged. |
|
|
|
Rebased as #13345 was merged (hooray!)! |
|
@jeenalee: Does this include new test results for all the tests? Working body methods will have changed the results from previous runs significantly. |
|
@jdm I built and ran |
|
@bors-servo: r+ |
|
|
Implement the Fetch method <!-- Please describe your changes on the following line: --> This PR implements the fetch method, which is described in [the Fetch Spec](https://fetch.spec.whatwg.org/#fetch-method). The expected wpt results are updated as well. A few comments about the current fetch implementation: - The fetch method manually calls `JSAutoCompartment` in order to prevent SpiderMonkey from crashing. This may have to change in the future. - Not all `FetchResponseListener` methods are implemented. - `net_traits::CoreResourceMsg::Fetch` message takes a `net_traits::request::RequestInit`. However, when the fetch method is called, a `RequestBinding::RequestInit` is given. The fetch method constructs a `dom::request::Request` with the given `RequestInit`, then creates `net_traits::request::RequestInit` from the dom Request object for the fetch message. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11898 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13323) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry |
Implement the Fetch method <!-- Please describe your changes on the following line: --> This PR implements the fetch method, which is described in [the Fetch Spec](https://fetch.spec.whatwg.org/#fetch-method). The expected wpt results are updated as well. A few comments about the current fetch implementation: - The fetch method manually calls `JSAutoCompartment` in order to prevent SpiderMonkey from crashing. This may have to change in the future. - Not all `FetchResponseListener` methods are implemented. - `net_traits::CoreResourceMsg::Fetch` message takes a `net_traits::request::RequestInit`. However, when the fetch method is called, a `RequestBinding::RequestInit` is given. The fetch method constructs a `dom::request::Request` with the given `RequestInit`, then creates `net_traits::request::RequestInit` from the dom Request object for the fetch message. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11898 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13323) <!-- Reviewable:end -->
|
|
jeenalee commentedSep 19, 2016
•
edited by larsbergstrom
This PR implements the fetch method, which is described in the Fetch Spec. The expected wpt results are updated as well.
A few comments about the current fetch implementation:
JSAutoCompartmentin order to prevent SpiderMonkey from crashing. This may have to change in the future.FetchResponseListenermethods are implemented.net_traits::CoreResourceMsg::Fetchmessage takes anet_traits::request::RequestInit. However, when the fetch method is called, aRequestBinding::RequestInitis given. The fetch method constructs adom::request::Requestwith the givenRequestInit, then createsnet_traits::request::RequestInitfrom the dom Request object for the fetch message../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is