Project

General

Profile

Feature #2631

Migrate to freedesktop.org definition of xattr mimetype

Added by MMN-o over 2 years ago. Updated over 1 year ago.

Status:
Fixed
Priority:
Low
Assignee:
-
Category:
core
Target version:
Start date:
2015-02-27
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

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?

Associated revisions

Revision 3131 (diff)
Added by stbuehler over 1 year ago

[stat] mimetype.xattr-name global config option (fixes #2631)

For backwards compatibility with existing lighttpd configs, default is
mimetype.xattr-name = "Content-Type"

Those who wish to use the freedesktop.org definition of xattr mimetype
can set the following in the global lighttpd config:
mimetype.xattr-name = "user.mime_type"

From: Glenn Strauss <>

Revision d17d48e0 (diff)
Added by gstrauss over 1 year ago

[stat] mimetype.xattr-name global config option (fixes #2631)

For backwards compatibility with existing lighttpd configs, default is
mimetype.xattr-name = "Content-Type"

Those who wish to use the freedesktop.org definition of xattr mimetype
can set the following in the global lighttpd config:
mimetype.xattr-name = "user.mime_type"

From: Glenn Strauss <>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3131 152afb58-edef-0310-8abb-c4023f1b3aa9

History

#1 Updated by stbuehler over 2 years ago

  • Target version set to 1.4.x

#2 Updated by gstrauss over 1 year 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?

#3 Updated by stbuehler over 1 year 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.

#4 Updated by gstrauss over 1 year ago

  • Status changed from New to Patch Pending

#5 Updated by stbuehler over 1 year ago

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

Applied in changeset r3131.

#6 Updated by stbuehler over 1 year ago

  • Target version changed from 1.4.x to 1.4.40

#7 Updated by gstrauss over 1 year 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
 ##

Also available in: Atom