Feature #2149
closedAutomatic Mime type detection via "File"
Description
The current way that Lighttpd detects a file's mime type is through the file extension, which is matched with the dictionary of file extensions by there MIME counterparts which is user-configured in the /etc/lighttpd/lighttpd.conf file via the "mimetype.assign" variable.
There are many problems with this: * Many obscure file extensions will not get detected. * Files without file extensions will be called an "octet-stream", even though they might not be. * If there is an error with the Mime type, browsers
Luckily there is a much easier way to detect file extensions, through the program "file" (comes default with most Linux distros, *BSD, Mac OS X).
It can be very easily done via bash with: "file -b --mime-encoding". Can also be done in C with the unistd.h header and execvp.
I believe that there should be setting, module, or some type of hack to allow Lighttpd to use "file" automatically instead of using a user configurable variable dictionary.
Updated by Olaf-van-der-Spek over 15 years ago
You can't execute a process each request due to performance reasons.
- Files without file extensions will be called an "octet-stream", even though they might not be.
That's a bug.
Updated by icy over 15 years ago
- Status changed from New to Invalid
As Olaf already mentioned, executing a program for each request would be a performance killer.
If you want to, you can use a FastCGI program which does this and use X-LIGHTTPD-send-file/X-sendfile to serve the actual file.
If the file has the mimetype as an extended fs attribute, you can also use mimetype.use-xattr = "enable".
Also available in: Atom