summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mod_compress.c6
-rw-r--r--tests/lighttpd.conf4
-rwxr-xr-xtests/mod-compress.t26
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");