I’m using the following headers to push downloads to the client from a generic path like /controller_name:
Transfer-Encoding: chunked
Content-Disposition: attachment
However, the browsers seem to be showing the ‘Save as’ dialog after all data is downloaded. Is there a way to show the dialog as soon as the download is about to start?
It turns out that this was caused by buffering in browsers. I guess the idea is that they let the download start early before presenting the user with a choice. Chrome is even more aggressive and saves short downloads for known types without prompting. There also seems to be a difference whether it happens over localhost or a remote server. For localhost it always buffers for me. This is confusing for developers though 🙂