Project

General

Profile

Actions

Feature #2149

closed

Automatic Mime type detection via "File"

Added by matthewbauer over 15 years ago. Updated over 15 years ago.

Status:
Invalid
Priority:
Normal
Category:
-
Target version:
-
ASK QUESTIONS IN Forums:

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.

Actions #1

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.

Actions #2

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".

Actions

Also available in: Atom