[w3c/ServiceWorker] Browsers should not consume the stream right away on ReadableStream responses with 'Content-Disposition: attachment' header. (#1398)

When providing the `FetchEvent.respondWith()` method with a Response object that has the `Content-Disposition` header set to `attachment` and a `ReadableStream` as its body, then if the browser is not set to automatic download mode and prompt the user with a window asking where to download the file or cancel the download, the stream should only be consumed if and when the user accepts the download.

Currently on both Firefox and Chrome, the browser starts consuming the stream as soon as the response is sent by the service worker. Meaning that while the window asking where to download the file / cancel the download is on the user's screen, the stream is pulling data non-stop and, it seems, storing it into memory.

I understand the need to fetch data immediately on inline content, however when the content is meant to be downloaded (`Content-Disposition: attachment`) then it makes no sense and can be dangerous to consume the stream right away if the browser is not set to automatic download mode. First because that means starting downloading data before having the user consent. Additionally, let's say this is a 10GB download, this means that without any transformation on the stream, the browser will potentially load 10GB in memory, which, apart for being an insane amount, can have unwanted side effects and will surely will crash the tab.

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

Received on Saturday, 30 March 2019 18:33:36 UTC