3 ms·
Years ago I had a problem serving downloads with PHP. IIRC it worked just fine on Opera (Presto-based) and was showing blank page on Firefox. The problem was s
by dzek69 7y ago
Years ago I had a problem serving downloads with PHP. IIRC it worked just fine on Opera (Presto-based) and was showing blank page on Firefox.
The problem was serving 404 Not Found status with `Content-Disposition: attachment` and actual contents of the file. Opera hadn't had a problem with that, Firefox was confused.
If you would like to test your browser behavior, here is replicated behaviour of what i've done in the past:
http://o7o.pl/down404.php http://o7o.pl/down404.php
My results:
- Chromium-based browsers (tested on Chrome, Vivaldi, Opera Developer) shows generic Chromium error with `ERR_INVALID_RESPONSE` code.
- Firefox displays own page about resource not being found
- Edge (not Chromish) removes the url (if opened in new tab) and shows infinite loader in the tab favicon or just restores previous url (if going to the url from another page)
- Old Presto-based Opera (newest from 12.x) just downloads the file
- wget just returns 404 error
- Internet Explorer 11 shows own "page cannot be found" page
Can anyone test it on Safari on Mac?
I wonder which should be the correct behavior? Personally I am satisfied with just downloading the file ignoring 404 status.
- 909090ffe4 7y ago- Safari shows a blank page, downloads it as a file, and auto-displays the content in TextEdit
- dzek69 7y ago> auto-displays the content in TextEdit wow, that's kind of "brave" thing to do for a file marked as `application/binary` mime type. it has `.txt` extension however as filename of course I have no idea how TextEdit behaves with big binary files, but such apps on Windows/Linux can't handle it well (usually hangs forever/for a long time)
- ambentzen 7y agoMacOS/Safari has an option to automatically open "safe" files, like text files and other media.
- Nextgrid 7y agoPDFs and ZIPs are also considered as safe despite the format being very complex and huge chances there's an exploitable bug in there. That's one of the very first things I disable on any Mac.
- dspillett 7y ago> Personally I am satisfied with just downloading the file ignoring 404 status. That would be convenient, and follows the "deal with it or ignore it and render what you can" pattern followed by browsers in the face of malformed HTML, but... > I wonder which should be the correct behavior? I'd argue that displaying the "not found" message, and aborting any other transfer, would be the more correct thing to do, despite being less convenient. Something thinks there is an error condition while responding the request, so can you really trust any content returned by the response to be as it should be?
- c1yd3i 7y agoSafari just downloaded a text file for me when I clicked the link. Nothing else happened.