[whatwg/fetch] Allow request/response.blob() to resolve before reading the full stream (#556)

>From https://github.com/whatwg/fetch/issues/554#issuecomment-308990694 by @asutherland:

> The blob() case is more efficient by far in terms of what the browser can and does optimize. Speaking for Gecko, the blob() call only creates a handle to the underlying file on disk. No reads of the file's contents need to be performed before returning the blob. This handle can be given to the new Response and passed across processes, allowing the target process to perform just the 1024-byte read directly, and without needing to involve the ServiceWorker or its global.

This is against the current spec which requires reading the full stream, but seems like a nice optimisation.

This should be limited to bodies with a known size, which means items with a `Content-Length` header, or items backed by disk (cache API).

The blob should enter an errored state if the body doesn't eventually match the size of the blob.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/556

Received on Tuesday, 20 June 2017 14:26:55 UTC