diff options
author | Jan Kneschke <jan@kneschke.de> | 2005-10-04 09:25:29 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2005-10-04 09:25:29 +0000 |
commit | 51d6e2abf0822bd4d9dac09c16b2cece26d65653 (patch) | |
tree | 4294f56ab6557648598ed065fbbc24077bb07bb4 | |
parent | 6cfb2582c409eacc5ec731568081e41853e3448a (diff) | |
download | lighttpd-git-51d6e2abf0822bd4d9dac09c16b2cece26d65653.tar.gz |
fixed output of non-cached compressed content and added test-cases
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@779 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | src/mod_compress.c | 6 | ||||
-rw-r--r-- | tests/lighttpd.conf | 4 | ||||
-rwxr-xr-x | tests/mod-compress.t | 26 |
3 files changed, 29 insertions, 7 deletions
diff --git a/src/mod_compress.c b/src/mod_compress.c index 67e1a443..def2be6c 100644 --- a/src/mod_compress.c +++ b/src/mod_compress.c @@ -514,7 +514,7 @@ static int deflate_file_to_buffer(server *srv, connection *con, plugin_data *p, chunkqueue_reset(con->write_queue); b = chunkqueue_get_append_buffer(con->write_queue); - buffer_copy_memory(b, p->b->ptr, p->b->used); + buffer_copy_memory(b, p->b->ptr, p->b->used + 1); buffer_reset(con->physical.path); @@ -663,7 +663,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) { response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag)); response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(sce->content_type)); - + return HANDLER_GO_ON; } } else if (0 == deflate_file_to_buffer(srv, con, p, @@ -672,7 +672,7 @@ PHYSICALPATH_FUNC(mod_compress_physical) { response_header_overwrite(srv, con, CONST_STR_LEN("Content-Encoding"), compression_name, strlen(compression_name)); response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(sce->content_type)); - return HANDLER_GO_ON; + return HANDLER_FINISHED; } break; } diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index d9dfd5b4..704c033a 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -64,7 +64,9 @@ mimetype.assign = ( ".png" => "image/png", ".c" => "text/plain", ".conf" => "text/plain" ) -compress.cache-dir = "@SRCDIR@/tmp/lighttpd/cache/compress/" +$HTTP["host"] == "cache.example.org" { + compress.cache-dir = "@SRCDIR@/tmp/lighttpd/cache/compress/" +} compress.filetype = ("text/plain", "text/html") setenv.add-environment = ( "TRAC_ENV" => "tracenv", "SETENV" => "setenv") diff --git a/tests/mod-compress.t b/tests/mod-compress.t index 5da77f91..3f1462ab 100755 --- a/tests/mod-compress.t +++ b/tests/mod-compress.t @@ -8,7 +8,7 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 7; +use Test::More tests => 9; use LightyTest; my $tf = LightyTest->new(); @@ -27,6 +27,16 @@ ok($tf->handle_http($t) == 0, 'Vary is set'); $t->{REQUEST} = ( <<EOF GET /index.html HTTP/1.0 Accept-Encoding: deflate +Host: no-cache.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ]; +ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set'); + +$t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Accept-Encoding: deflate +Host: cache.example.org EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ]; @@ -35,12 +45,23 @@ ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is $t->{REQUEST} = ( <<EOF GET /index.html HTTP/1.0 Accept-Encoding: gzip +Host: no-cache.example.org EOF ); -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '' } ]; +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ]; ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set'); $t->{REQUEST} = ( <<EOF +GET /index.html HTTP/1.0 +Accept-Encoding: gzip +Host: cache.example.org +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ]; +ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set'); + + +$t->{REQUEST} = ( <<EOF GET /index.txt HTTP/1.0 Accept-Encoding: gzip, deflate EOF @@ -56,5 +77,4 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain" } ]; ok($tf->handle_http($t) == 0, 'Content-Type is from the original file'); - ok($tf->stop_proc == 0, "Stopping lighttpd"); |