Project

General

Profile

Actions

Feature #2631

closed

Migrate to freedesktop.org definition of xattr mimetype

Added by MMN-o over 6 years ago. Updated over 5 years ago.

Status:
Fixed
Priority:
Low
Category:
core
Target version:
ASK QUESTIONS IN Forums:

Description

I read on http://redmine.lighttpd.net/projects/1/wiki/Mimetype_use-xattrDetails that lighttpd will look at a user-defined xattr value under the "Content-Type" key.

I recently saw similar functionality in Apache's "mod-mime-xattr", https://packages.debian.org/fr/sid/httpd/libapache2-mod-mime-xattr

The documentation for Apache's mime xattr references freedesktop.org specifications, which states that the "user.mime_type" key should be used: http://standards.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html#idm140622087713936

I quote with lost formatting:
"Storing the MIME type using Extended Attributes
An implementation MAY also get a file's MIME type from the user.mime_type extended attribute. [...]"

So how about lighttpd starts using the freedesktop.org defined value (user.mime_type) and maybe just use Content-Type as fallback?

Actions #1

Updated by stbuehler over 6 years ago

  • Target version set to 1.4.x
Actions #2

Updated by gstrauss over 5 years ago

Perhaps a new config option mimetype.xattr-name could be used to specify the attribute name

mimetype.xattr-name = "Content-Type"    /* default for lighttpd backward compatibility */
mimetype.xattr-name = "user.mime-type"  /* user-specified to match freedesktop spec */

I'd be tempted to make this T_CONFIG_SCOPE_SERVER rather than T_CONFIG_SCOPE_CONNECTION to avoid the marginal cost of config merging.

stbuehler, would you accept such a patch?

Actions #3

Updated by stbuehler over 5 years ago

  • Tracker changed from Bug to Feature

I agree with T_CONFIG_SCOPE_SERVER; a lot of stat() calls are not made on the target file directly, and therefore it sounds wrong to make this dependent on path / filename extension conditionals.

Actions #4

Updated by gstrauss over 5 years ago

  • Status changed from New to Patch Pending
Actions #5

Updated by stbuehler over 5 years ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Applied in changeset r3131.

Actions #6

Updated by stbuehler over 5 years ago

  • Target version changed from 1.4.x to 1.4.40
Actions #7

Updated by gstrauss over 5 years ago

I neglected to update the doc when adding the new directive. Would you add the following? Thanks.

diff --git a/doc/config/conf.d/mime.conf b/doc/config/conf.d/mime.conf
index c4d6ce4..8d8d69c 100644
--- a/doc/config/conf.d/mime.conf
+++ b/doc/config/conf.d/mime.conf
@@ -8,8 +8,19 @@
 ## https://redmine.lighttpd.net/projects/lighttpd/wiki/Mimetype_assignDetails

 ##
-## Use the "Content-Type" extended file attribute to obtain mime type if
-## possible
+## mimetype.xattr-name
+## Set the extended file attribute name used to obtain mime type
+## (must also set mimetype.use-xattr = "enable")
+##
+## Default value is "Content-Type" 
+##
+## freedesktop.org Shared MIME-info Database specification suggests
+## user-defined value ("user.mime_type") as name for extended file attribute
+#mimetype.xattr-name = "user.mime_type" 
+
+##
+## Use extended attribute named in mimetype.xattr-name (default "Content-Type")
+## to obtain mime type if possible
 ##
 ## Disabled by default
 ##
Actions

Also available in: Atom