What can cause a browser (Chrome) to generate a download
I am playing with experimental webRequest API from chrome.
The goal is to identify web request that will pop up a download window.
For the moment, my filtering is based on file extension a开发者_StackOverflow社区nd that filters pretty well, but I want to block any kind of file, even if they don't have an extension.
I am pretty sure HTTP Response Headers can help me identify the responses that will be treated as download.
Have you any idea of which one(s) will trigger it?
Thanks,
Florent
You're looking for a Content-Disposition which specifies attachment.
[edit] You may also have to look for a content-type of application/force-download. [/edit]
There is a HTML header that looks like this:
Content-type: application/pdf
You can use look at that information, and only whitelist (as opposed to blacklist) the good content-types.
Most browsers give a functionality to specify how to handle files with specific extension beyond the common once (html,php,asp, etc). Every user can customize the experience. For example, one user, an mp4 file may be directly played in it by using some plug-in while other may offer it for download.
You will probably have to play with your calculation and assume that files with out typical web-page extensions are downloadable.
I believe anything with a content-type that the browser doesn't understand will force it to download. Example:
$mimeType = 'application/force-download';
精彩评论