Re: [slightlyoff/ServiceWorker] Create a new ReadableStream in FetchEvent.respondWith (#934)

>                            </ol>
> -                          <p class="note">These substeps are meant to produce the observable equivalent of "piping" response's <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a>'s <a>stream</a> into potentialResponse. That is, response is left with a <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a> with a <a>ReadableStream</a> object that is <a>disturbed</a> and <a>locked</a>, while the data readable from potentialResponse's <a>body</a>'s <a>stream</a> is now equal to what used to be response's, if response's original <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a> is non-null.</p>
> -                          <p class="issue">These substeps will be replaced by <a href="https://github.com/slightlyoff/ServiceWorker/issues/850#issuecomment-197893295">using pipe</a> when the algorithm for <a href="https://streams.spec.whatwg.org/#rs-pipe-to">pipeTo</a> becomes stable.</p>
> +                          <p class="note">These substeps are meant to produce the observable equivalent of "piping" response's <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a>'s <a>stream</a> into potentialResponse.</p>
> +                          <p class="issue">The user agent doesn't need to preserve buffers' boundary although the above steps require it. These substeps will be replaced by <a href="https://github.com/whatwg/fetch/issues/330#issuecomment-231947405">using pipe</a> when the algorithm for <a href="https://streams.spec.whatwg.org/#rs-pipe-to">pipeTo</a> becomes stable and that will resolve this inconsistency.</p>

I think it is possible to spec these even without using pipeTo, if you want. When the promise fulfills with a value, transfer it, but then just say something like "store it in _chunkStorage_" instead of enqueueing it. Then, add a step after constructing newStream saying something like "As _chunkStorage_ gains entries, enqueue new Uint8Array objects into _newStream_ in sequence such that their concatenated result is the same as the concatenated result of the values in _chunkStorage_." Maybe add a note explaining, like "This is intended to allow the user agent to arbitrarily change chunk boundaries between _response_'s body's stream and _newStream_."

---
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/pull/934/files/06dd419a6b375f0a6a010323ee6c87c683290523#r72921564

Received on Monday, 1 August 2016 03:52:41 UTC