Skip to content
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

Add Mimetype Support #10

Open
MaStr opened this issue Apr 15, 2012 · 1 comment
Open

Add Mimetype Support #10

MaStr opened this issue Apr 15, 2012 · 1 comment
Milestone

Comments

@MaStr
Copy link
Member

MaStr commented Apr 15, 2012

Currently, almost any uploaded file is considered 'application/octet-stream' by the web server, which prevents the browser to handle it correctly and force it to be downloaded.

The problem lies with the way the python SimpleHTTPServer handles files, by default, it serves anything as a binary blob, except for .c, .h, and .py files which are considered plain text.
Theoretically, it should read the default mimetype files from the system and use that to find out the mimetype to give for an extension, but it does not seem to work.

So you just have to get a complete mimetypes file from your system (here is mine), add it to your piratebox (like in /etc/ or whatever), and fix the python code so that it reads it, by modifying the /mnt/ext/usr/lib/python2.6/SimpleHTTPServer.py file at line 202,
change

        mimetypes.init()

with

        mimetypes.init(files=['/etc/mime.types'])

And it should work (also, my SimpleHTTPServer.py).

A cleaner way would be to create a class that inherits SimpleHTTPServer, but since the python on the piratebox isn’t meant to be updated or used by anything else, I am not sure it is worth the effort.

@MaStr
Copy link
Member Author

MaStr commented May 8, 2012

first implementation... static filename ..

MaStr added a commit that referenced this issue May 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant