servo: Merge #13895 - Implement Step 1 of Response API Clone Method (from lautat:dom-response-clone-step-1); r=KiChjang
authorAtte Lautanala <atte.lautanala@gmail.com>
Sun, 23 Oct 2016 07:55:30 -0500
changeset 339975 c9b78d30a607becab058a376b0a1b1224aeb4426
parent 339974 58c2650fd3c0e0c11a242b0f8a6dcea644311904
child 339976 aa57bae4715bbf35f51b6e2a64126a1db711e19d
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersKiChjang
servo: Merge #13895 - Implement Step 1 of Response API Clone Method (from lautat:dom-response-clone-step-1); r=KiChjang <!-- Please describe your changes on the following line: --> Implements first step of response API Clone method. Response Clone test expectations have been updated. Fixes issue #13888. --- <!-- 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 #13888. <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 2772626d91502222c687f30db32393634017b129
servo/components/script/dom/response.rs
--- a/servo/components/script/dom/response.rs
+++ b/servo/components/script/dom/response.rs
@@ -293,17 +293,19 @@ impl ResponseMethods for Response {
     // https://fetch.spec.whatwg.org/#dom-response-headers
     fn Headers(&self) -> Root<Headers> {
         self.headers_reflector.or_init(|| Headers::for_response(&self.global()))
     }
 
     // https://fetch.spec.whatwg.org/#dom-response-clone
     fn Clone(&self) -> Fallible<Root<Response>> {
         // Step 1
-        // TODO: This step relies on body and stream, which are still unimplemented.
+        if self.is_locked() || self.body_used.get() {
+            return Err(Error::Type("cannot clone a disturbed response".to_string()));
+        }
 
         // Step 2
         let new_response = Response::new(&self.global());
         new_response.Headers().set_guard(self.Headers().get_guard());
         try!(new_response.Headers().fill(Some(HeadersInit::Headers(self.Headers()))));
 
         // https://fetch.spec.whatwg.org/#concept-response-clone
         // Instead of storing a net_traits::Response internally, we