Re: [fetch] Service worker request body reads need to invoke callbacks (#87)

Answering your question from IRC, which I understand more than the above:

> A document invokes fetch() and passes a body. A service worker gets that request and passes it to fetch(). Can both the document and the service worker observe the stream being read from for the purpose of progress events?

I'm not sure exactly what you mean by "observe the stream being read from." I would say that only the person doing the reading will observe the reads happening. Who they want to pass that information on to is up to them.

In this scenario,

- In-document fetch() reads from the in-document body, as part of the process of "transfering the stream" over to the service worker. (I.e., constructing a second stream object over in the service worker, and filling it with the chunks read from the original one.)
- In-SW fetch() reads from the in-SW body, as part of the process of uploading it to the network.

In both cases, the party doing the reading can choose to tell other parties, or emit progress events, as appropriate.

Maybe the todo here is for https://github.com/whatwg/streams/issues/276 to be sure to include a hook for other specs to say e.g. "transfer with chunk-action X" instead of just "transfer," to allow action during the transfer.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/87#issuecomment-124302749

Received on Friday, 24 July 2015 03:10:22 UTC