- From: Domenic Denicola <notifications@github.com>
- Date: Tue, 20 Jan 2015 11:40:19 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/452/70718250@github.com>
Thanks @annevk for helping remind me what `bodyUsed` was meant for. Namely, something developers can use to avoid try/catch with the convenience methods `text()` etc. With that in mind I think `bodyUsed`, perhaps with a better name, should be true when any of the following is true: 1. The stream is currently locked 2. The stream is "closed" or "errored" but has Content-Length > 0. I think that might be enough? That is, I think these are all of the cases where cloning or the convenience methods will fail. A couple things to note: - If the stream has been partially read (using `.read()`) but not read to the end, `bodyUsed` should be false, since you could still call `.text()` or clone it and get something useful. - If `text()` is ever called on a non-empty body, then bodyUsed will be true, since either the stream will be currently locked, or it will have been closed/errored before being unlocked. - If `text()` is called on an empty stream, then there is no effect. It is safe to call `.text()` on an empty stream as many times as you want. Does this sound good? Did I miss anything? --- Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/452#issuecomment-70718250
Received on Tuesday, 20 January 2015 19:40:48 UTC