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
svn/tags/lighttpd-1.4.24
Stefan Bühler 2009-10-11 19:27:55 +00:00
parent af3961c9d9
commit d21c645bfa
4 changed files with 17 additions and 5 deletions

1
NEWS
View File

@ -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)

View File

@ -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;

View File

@ -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" {

View File

@ -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');