summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2009-10-11 19:27:55 +0000
committerStefan Bühler <stbuehler@web.de>2009-10-11 19:27:55 +0000
commitd21c645bfa5af432d22e5d54c989b68c20ad48f6 (patch)
treeeb253fc1e1349dd195f841c3f5a680ec6c75b4f3
parentaf3961c9d9939fd23a2637a7c4c1dd8b535908c7 (diff)
downloadlighttpd-git-d21c645bfa5af432d22e5d54c989b68c20ad48f6.tar.gz
mod_compress: match partial+full content-type (fixes #1552)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2634 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--NEWS1
-rw-r--r--src/mod_compress.c13
-rw-r--r--tests/mod-compress.conf2
-rwxr-xr-xtests/mod-compress.t6
4 files changed, 17 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 96935741..6f7f9762 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ NEWS
* mod_webdav: Delete old properties before updating new for MOVE (fixes #1317)
* Read hostname from absolute uris in the request line (fixes #1937)
* mod_fastcgi: don't disable backend if disable-time is 0 (fixes #1825)
+ * mod_compress: match partial+full content-type (fixes #1552)
- 1.4.23 - 2009-06-19
* Added some extra warning options in cmake and fix the resulting warnings (unused/static functions)
diff --git a/src/mod_compress.c b/src/mod_compress.c
index f53174d8..12939506 100644
--- a/src/mod_compress.c
+++ b/src/mod_compress.c
@@ -661,6 +661,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
off_t max_fsize;
stat_cache_entry *sce = NULL;
buffer *mtime = NULL;
+ buffer *content_type;
if (con->mode != DIRECT || con->http_status) return HANDLER_GO_ON;
@@ -713,6 +714,15 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
if (sce->st.st_size < 128) return HANDLER_GO_ON;
/* check if mimetype is in compress-config */
+ content_type = 0;
+ if (sce->content_type->ptr) {
+ char *c;
+ if ( (c = strchr(sce->content_type->ptr, ';')) != 0) {
+ content_type = srv->tmp_buf;
+ buffer_copy_string_len(content_type, sce->content_type->ptr, c - sce->content_type->ptr);
+ }
+ }
+
for (m = 0; m < p->conf.compress->used; m++) {
data_string *compress_ds = (data_string *)p->conf.compress->data[m];
@@ -722,7 +732,8 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
return HANDLER_GO_ON;
}
- if (buffer_is_equal(compress_ds->value, sce->content_type)) {
+ if (buffer_is_equal(compress_ds->value, sce->content_type)
+ || (content_type && buffer_is_equal(compress_ds->value, content_type))) {
/* mimetype found */
data_string *ds;
diff --git a/tests/mod-compress.conf b/tests/mod-compress.conf
index 8d43b009..b7c3f2cb 100644
--- a/tests/mod-compress.conf
+++ b/tests/mod-compress.conf
@@ -22,7 +22,7 @@ server.modules = (
mimetype.assign = (
".html" => "text/html",
- ".txt" => "text/plain",
+ ".txt" => "text/plain; charset=utf-8",
)
$HTTP["host"] == "cache.example.org" {
diff --git a/tests/mod-compress.t b/tests/mod-compress.t
index 63f3d2ae..966f6130 100755
--- a/tests/mod-compress.t
+++ b/tests/mod-compress.t
@@ -76,7 +76,7 @@ GET /index.txt HTTP/1.0
Accept-Encoding: gzip, deflate
EOF
);
-$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain" } ];
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
ok($tf->handle_http($t) == 0, 'Content-Type is from the original file');
$t->{REQUEST} = ( <<EOF
@@ -87,7 +87,7 @@ User-Agent: MYOB/6.66 (AN/ON)
Connection: close
EOF
);
-$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Type' => "text/plain" } ];
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
ok($tf->handle_http($t) == 0, 'Empty Accept-Encoding');
$t->{REQUEST} = ( <<EOF
@@ -96,7 +96,7 @@ Accept-Encoding: bzip2, gzip, deflate
Host: cache.example.org
EOF
);
-$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain" } ];
+$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain; charset=utf-8" } ];
ok($tf->handle_http($t) == 0, 'bzip2 requested but disabled');