- From: Jake Archibald <notifications@github.com>
- Date: Tue, 22 Jan 2019 15:15:49 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1384/review/195059550@github.com>
jakearchibald commented on this pull request. > - 1. If |response| is [=Body/disturbed=] or [=Body/locked=], return [=a promise rejected with=] a `TypeError`. - 1. Let |clonedResponse| be the result of [=response/clone|cloning=] |response|'s associated [=Response/response=]. - 1. If |response|'s body is non-null, run these substeps: - 1. Let |dummyStream| be an [=empty=] {{ReadableStream}} object. - 1. Set |response|'s [=response/body=] to a new [=/body=] whose [=stream=] is |dummyStream|. - 1. Let |reader| be the result of [=get a reader|getting a reader=] from |dummyStream|. - 1. [=Read all bytes=] from |dummyStream| with |reader|. + 1. If |response|'s [=response/body=] is [=Body/disturbed=] or [=Body/locked=], return [=a promise rejected with=] a `TypeError`. + 1. Let |clonedResponse| be a [=response/clone=] of |response|. + 1. Let |bodyReadPromise| be [=a promise resolved with=] undefined. + 1. If |response|'s [=response/body=] is non-null, run these substeps: + 1. Let |stream| be |response|'s [=response/body=]'s [=body/stream=]. + 1. Let |reader| be the result of [=ReadableStream/get a reader|getting a reader=] for |stream|. + 1. Set |bodyReadPromise| to the result of [=Read all bytes|reading all bytes=] from |stream| with |reader|. + + Note: This ensures that |response|'s [=response/body=] is [=Body/locked=], and we have a full buffered copy of the body in |clonedResponse|. @annevk `|bodyReadPromise|` is returned at the end of this algorithm, so any rejection there will become a rejection of `cache.put()`. @wanderview good point. I'll expand on that. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/pull/1384#discussion_r249822730
Received on Tuesday, 22 January 2019 15:16:13 UTC