3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 11;
14 my $tf = LightyTest
->new();
17 $tf->{CONFIGFILE
} = 'mod-compress.conf';
19 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
21 $t->{REQUEST
} = ( <<EOF
22 GET /index.html HTTP/1.0
23 Accept-Encoding: deflate
26 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '' } ];
27 ok
($tf->handle_http($t) == 0, 'Vary is set');
29 $t->{REQUEST
} = ( <<EOF
30 GET /index.html HTTP/1.0
31 Accept-Encoding: deflate
32 Host: no-cache.example.org
35 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ];
36 ok
($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
38 $t->{REQUEST
} = ( <<EOF
39 GET /index.html HTTP/1.0
40 Accept-Encoding: deflate
41 Host: cache.example.org
44 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ];
45 ok
($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
47 $t->{REQUEST
} = ( <<EOF
48 GET /index.html HTTP/1.0
50 Host: no-cache.example.org
53 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ];
54 ok
($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
56 $t->{REQUEST
} = ( <<EOF
57 GET /index.html HTTP/1.0
59 Host: cache.example.org
62 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ];
63 ok
($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
66 $t->{REQUEST
} = ( <<EOF
67 GET /index.txt HTTP/1.0
68 Accept-Encoding: gzip, deflate
71 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '' } ];
72 ok
($tf->handle_http($t) == 0, 'gzip, deflate - Content-Length and Content-Encoding is set');
74 $t->{REQUEST
} = ( <<EOF
75 GET /index.txt HTTP/1.0
76 Accept-Encoding: gzip, deflate
79 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
80 ok
($tf->handle_http($t) == 0, 'Content-Type is from the original file');
82 $t->{REQUEST
} = ( <<EOF
83 GET /index.txt HTTP/1.0
85 X-Accept-encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0
86 User-Agent: MYOB/6.66 (AN/ON)
90 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
91 ok
($tf->handle_http($t) == 0, 'Empty Accept-Encoding');
93 $t->{REQUEST
} = ( <<EOF
94 GET /index.txt HTTP/1.0
95 Accept-Encoding: bzip2, gzip, deflate
96 Host: cache.example.org
99 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain; charset=utf-8" } ];
100 ok
($tf->handle_http($t) == 0, 'bzip2 requested but disabled');
103 ok
($tf->stop_proc == 0, "Stopping lighttpd");