Re: [ServiceWorker] Can we change the body attribute of Request/Response to a method? (#606)

Re: @annevk https://github.com/slightlyoff/ServiceWorker/issues/606#issuecomment-70988920

Domenic's summary at https://github.com/whatwg/streams/issues/269#issue-55052562 explains it. We want to be able to have the browser refrain from populating the ReadableStream until we say "Go" for that.

Once a ReadableStream instance is created, it runs `start()` of the underlying source https://streams.spec.whatwg.org/#underlying-source, and if it finishes, starts calling `pull()` of the underlying source. This starts retrieving data from the browser process and buffering in the renderer process.

This "buffering" is what Horo wanted to avoid. This happens when a ReadableStream is created and `start()` of its underlying source is finished. No when `.read()` is called.

`.read()` is a synchronous method. So, the renderer should be able to return some data synchronously. So, `.read()` cannot work as the trigger of the data retrieval which is asynchronous. Only the followings can work as a trigger
- construction of the ReadableStream
- completion of `start()`

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/606#issuecomment-70991972

Received on Thursday, 22 January 2015 09:19:53 UTC