-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Content-Type results in firmware files opening in the browser #1059
Comments
Context chain:
All that is to say: ASU should probably register |
@AliveDevil So mimetypes not recognizing ".img" is one thing - but in my example the file ending is ".gz". It seems guess_type reads the mime-types from system files, which maybe are missing in the docker image? |
Check the godbolt output: Python can guess encoding and file type separately. Starlette only cares about the guessed type: in this case .img evaluates to None, which is then falled back to text/plain. This could be fixed by editing the mime.types file, or just fixed in application code, which would be less error-prone for users. |
So this would mean we have to do mimetypes.add_type for other File Extensions too. I queried the firmware names and found the following non-duplicated list:
So because anyway ASU provides Firmware-Files always it should always set Maybe something along these lines? class FirmwareFiles(StaticFiles):
async def get_response(self, path: str, scope):
response = await super().get_response(path, scope)
response.headers["Content-Type"] = "application/octet-stream"
return response
app.mount("/store", FirmwareFiles(directory=settings.public_path / "store"), name="store") |
Hi, I love how you analyze the issue and come up with ideas. I'm currently a bit focused to spent my OpenWrt time on the APK migration so don't really do stuff for ASU. If you need anything specific, please ping me. |
This is the current Caddyfile, maybe someone got an idea how to improve it?
|
Can create a PR tomorrow (CET) with an improved staticfiles handler. the bandaid solution would be Caddy |
Download-Links to a notable amount of built Images via the Browser-Interface of the public Firmware-Selector-Server on the public ASU are being advertised as
content-type: text/stream; charset=utf-8
instead of fromcontent-type: application/octet-stream
the Webserver running on ASU.This leads to the Issue where, when clicking on the Download-Button, instead of Firefox opening the Download-File-Dialog, it interprets the File as a Webpage and tries to render it. Workaround is clicking "Save Target as".
I am not sure if I should put this here or at firmware-selector-openwrt-org - therefore I created a Ticket there too.
While Chrome Browser seems to take care of this misconfiguration, Firefox doesn't.
The text was updated successfully, but these errors were encountered: