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

> @@ -1784,14 +1790,22 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
>                          <li>Let <var>potentialResponse</var> be a copy of <var>response</var>'s associated <a href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>, except for its body.</li>
>                          <li>If <var>response</var>'s body is non-null, run these substeps:
>                            <ol>
> -                            <li>Set <var>potentialResponse</var>'s <a>body</a> to <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a>.</li>
> -                            <li>Let <var>dummyStream</var> be an <a>empty</a> <a>ReadableStream</a> object.</li>
> -                            <li>Set <var>response</var>'s <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a> to a new <a>body</a> whose <a>stream</a> is <var>dummyStream</var>.</li>
> -                            <li>Let <var>reader</var> be the result of <a lt="get a reader">getting a reader</a> from <var>dummyStream</var>.</li>
> -                            <li><a>Read all bytes</a> from <var>dummyStream</var> with <var>reader</var>.</li>
> +                            <li>Let <var>reader</var> be the result of <a lt="get a reader">getting a reader</a> from <var>response</var>'s <a>body</a>'s <a>stream</a>.</li>
> +                            <li>Let <var>strategy</var> be an object. The user agent may choose any object.</li>
> +                            <li>Let <var>pull</var> be an action that runs these subsubsteps:
> +                              <ol>
> +                                <li>Let <var>promise</var> be the result of <a lt="read a chunk from a reader">reading</a> a chunk from <var>reader</var>.</li>
> +                                <li>When <var>promise</var> is fulfilled with an object whose <code>done</code> property is false and whose <code>value</code> property is a <code>Uint8Array</code> object, <a lt="enqueue a chunk to ReadableStream">enqueue</a> the result of transferring the <code>value</code> property to <var>newStream</var>.

"transferring" is overly-imprecise here. Let _chunk_ be the value of the `value` property. Let _targetRealm_ be the [relevant Realm](https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm) of this `FetchEvent`. Then the transferred object is [TransferHelper](https://html.spec.whatwg.org/multipage/infrastructure.html#transferhelper-(-input,-targetrealm-))(_chunk_, _targetRealm_).

(We should probably rename TransferHelper. But for now use 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/slightlyoff/ServiceWorker/pull/934/files/06dd419a6b375f0a6a010323ee6c87c683290523#r72921255

Received on Monday, 1 August 2016 03:45:05 UTC