ignore return value from fcntl() FD_CLOEXEC
[lighttpd.git] / tests / mod-compress.t
blob966f6130bf91bda3ee0664921c63423b6d9eaaac
1 #!/usr/bin/env perl
2 BEGIN {
3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s,/[^/]+$,/,;
6 unshift @INC, $srcdir;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 11;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
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
24 EOF
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
33 EOF
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
42 EOF
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
49 Accept-Encoding: gzip
50 Host: no-cache.example.org
51 EOF
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
58 Accept-Encoding: gzip
59 Host: cache.example.org
60 EOF
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
69 EOF
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
77 EOF
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
84 Accept-encoding:
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)
87 Connection: close
88 EOF
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
97 EOF
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");