[ServiceWorker] FetchEvent.respondWith does something weird with the body of a response (#850)

In the algorithm describing respondWith the following steps exist:

1. Set the _potential response_ to _response_’s associated response.
2. If _response_’s body is non-null, run these substeps:
  1. Let dummyStream be an empty ReadableStream object.
  2. Set _response_’s body to a new body whose stream is dummyStream.
  3. Let reader be the result of getting a reader from dummyStream.
  4. Read all bytes from dummyStream with reader.

I think this is incorrect, although I'm not entirely sure what it is trying to do.

What it seems to say it is doing is assigning a new body to response's body (not sure how that is possible, _response_'s body is defined as being the body of _response_'s associated response. There doesn't seem to be a way to change the body of just the `Response` object while leaving the body of the underlying response alone). It then goes and reads all the bytes from this newly created empty body.

I'm guessing the intended effect is to leave the javascript `Response` object with a disturbed body, which happens to be an empty stream, while leaving the underlying response alone. But the fetch spec doesn't allow decoupling the body of the `Response` object from the body of the associated response, so what is written doesn't actually work.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/850

Received on Tuesday, 15 March 2016 23:56:29 UTC