static-file-server
static-file-server copied to clipboard
Served DMG files are opened on Safari instead of being downloaded
Hi,
We are using your static-file-server to serve binary files. Lately, we have found that when we request a DMG that is being served by static-file-server on a Safari browser, it gets open as binary in the browser, instead of being downloaded. The same doesn't happen on Chrome though as the file gets downloaded normally.
I wonder if you have ever crossed yourself with this behaviour and know how to fix it.
I saw that there was an update in the last month and tried to use an older version. Same behaviour.
I know that this problem didn't happen before and I'm not sure if this is a Safari issue or a static-file-server issue.
Thanks!
Not being a Safari user, I can't speak specifically to that browser, but generally speaking, what I think is happening is that the static-file-server is setting the "Content-Type" HTTP header that the browser then interprets to decide how the user wants to view the file. For example, a Python source file is "text/x-python", a PNG is "image/png" and an MP4 video is "video/mp4". In these cases, at least on my computer, all of these are rendered in the browser. I expect that Safari is interpreting the "Content-Type" HTTP header and using that to try to render it in the browser. In Chrome, at least, if you press ctrl+shift+i to open the dev tools and open the "Network" tab, then open the file, click on the network entry, you can then see the "Response Headers" to know what the static-file-server is assigning. As for changing the behavior of Safari, that is outside of my ability to test (I only have Linux computers, which doesn't have Safari available as an install option). If the "Content-Type" header is obviously wrong, please upload a minimal example file, the "Content-Type" you expect and what you are getting to this issue and I can work on a fix from that.