Re: [ServiceWorker] Backpressure on fetch integrated with Streams (#452)

> We definitely want to allow read and then call json(), e.g. for a file format that has descriptive headers then JSON content

Sorry I missed this earlier, but this seems to add a complexity for only a small amount of convenience gain.

I think it would be a lot more straightforward if client code decided up front if they wanted streaming or non-streaming behavior.  If they want non-streaming, then use the convenience routines like json().  Otherwise use read() for streaming.  Don't mix the two.

I think the right way to provide a json()-like convenience routine for streams would be to define a JsonStreamReader() or ConsumeAsJson() function.  These would use read() to drain the stream and convert to json.  This would have the added benefit of working with any stream; not just Request/Response.

Unless there is another reason for read() not to mark bodyUsed, I still vote for marking the flag on the first byte read from the stream.

Anyway, just my two cents.  Sorry again if this was discussed long ago and I missed it.

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

Received on Saturday, 29 November 2014 23:34:56 UTC