Posted on Mo 23 Januar 2006

Adding Extended Attribute Support to Apache 2.0

I updated my little Apache module mod_mime_xattr to be compatible with Apache 2.0.

What is it useful for? Linux (2.4 with patch, 2.6 out-of-the-box) has been supporting extended attributes for files (EAs) for ages, but very few applications use them. To change that I wrote a small module for Apache which interpretes the EA user.mime_type and uses its value as MIME type for all files served by Apache. The EA has been standardized by the XDG MIME system, but apparently neither Gnome nor KDE support it right now.

Usage of mod_mime_xattr is simple. To enable interpretation of the EA on the entire tree use something like this in your Apache configuration file:

<Directory />
XAttrMimeType On

That's all that is required to make use of user.mime_type on all files where it is set. To set the EA use a command like this one:

setfattr -n "user.mime_type" -v "text/html" foo.txt

And foo.txt will become a file with the MIME type of text/html, although its suffix is .txt!

© Lennart Poettering. Built using Pelican. Theme by Giulio Fidente on github. .