Browse Source

Allow xattr to overwrite mime type (fixes #1929)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2425 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
b3027fef1c
  1. 1
      NEWS
  2. 36
      src/stat_cache.c

1
NEWS

@ -9,6 +9,7 @@ NEWS
* Create rrd file for empty rrdfile in mod_rrdtool (#1788)
* Fix workaround for incorrect path info/scriptname if fastcgi prefix is "/" (fixes #729)
* Finally removed spawn-fcgi
* Allow xattr to overwrite mime type (fixes #1929)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

36
src/stat_cache.c

@ -595,29 +595,31 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
if (S_ISREG(st.st_mode)) {
/* determine mimetype */
buffer_reset(sce->content_type);
for (k = 0; k < con->conf.mimetypes->used; k++) {
data_string *ds = (data_string *)con->conf.mimetypes->data[k];
buffer *type = ds->key;
if (type->used == 0) continue;
/* check if the right side is the same */
if (type->used > name->used) continue;
if (0 == strncasecmp(name->ptr + name->used - type->used, type->ptr, type->used - 1)) {
buffer_copy_string_buffer(sce->content_type, ds->value);
break;
}
}
etag_create(sce->etag, &(sce->st), con->etag_flags);
#ifdef HAVE_XATTR
if (con->conf.use_xattr && buffer_is_empty(sce->content_type)) {
stat_cache_attr_get(sce->content_type, name->ptr);
}
#endif
/* xattr did not set a content-type. ask the config */
if (buffer_is_empty(sce->content_type)) {
for (k = 0; k < con->conf.mimetypes->used; k++) {
data_string *ds = (data_string *)con->conf.mimetypes->data[k];
buffer *type = ds->key;
if (type->used == 0) continue;
/* check if the right side is the same */
if (type->used > name->used) continue;
if (0 == strncasecmp(name->ptr + name->used - type->used, type->ptr, type->used - 1)) {
buffer_copy_string_buffer(sce->content_type, ds->value);
break;
}
}
}
etag_create(sce->etag, &(sce->st), con->etag_flags);
} else if (S_ISDIR(st.st_mode)) {
etag_create(sce->etag, &(sce->st), con->etag_flags);
etag_create(sce->etag, &(sce->st), con->etag_flags);
}
#ifdef HAVE_FAM_H

Loading…
Cancel
Save