2005-09-01 11:44:57 +00:00
|
|
|
#!/usr/bin/env perl
|
2005-06-26 10:27:41 +00:00
|
|
|
BEGIN {
|
2008-01-15 22:03:59 +00:00
|
|
|
# add current source dir to the include-path
|
|
|
|
# we need this for make distcheck
|
|
|
|
(my $srcdir = $0) =~ s,/[^/]+$,/,;
|
|
|
|
unshift @INC, $srcdir;
|
2005-06-26 10:27:41 +00:00
|
|
|
}
|
2005-03-02 11:27:02 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use IO::Socket;
|
2008-10-03 10:05:33 +00:00
|
|
|
use Test::More tests => 11;
|
2005-06-15 09:37:18 +00:00
|
|
|
use LightyTest;
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
my $tf = LightyTest->new();
|
|
|
|
my $t;
|
2006-10-05 00:09:51 +00:00
|
|
|
|
2008-10-03 10:05:33 +00:00
|
|
|
$tf->{CONFIGFILE} = 'mod-compress.conf';
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->start_proc == 0, "Starting lighttpd") or die();
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-03-02 11:27:02 +00:00
|
|
|
GET /index.html HTTP/1.0
|
|
|
|
Accept-Encoding: deflate
|
|
|
|
EOF
|
|
|
|
);
|
2005-08-31 12:55:44 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '' } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'Vary is set');
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-03-02 11:27:02 +00:00
|
|
|
GET /index.html HTTP/1.0
|
|
|
|
Accept-Encoding: deflate
|
2005-10-04 09:25:29 +00:00
|
|
|
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
|
2005-03-02 11:27:02 +00:00
|
|
|
EOF
|
|
|
|
);
|
2005-08-31 12:55:44 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-03-02 11:27:02 +00:00
|
|
|
GET /index.html HTTP/1.0
|
|
|
|
Accept-Encoding: gzip
|
2005-10-04 09:25:29 +00:00
|
|
|
Host: no-cache.example.org
|
2005-03-02 11:27:02 +00:00
|
|
|
EOF
|
|
|
|
);
|
2005-10-04 09:25:29 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-10-04 09:25:29 +00:00
|
|
|
$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');
|
|
|
|
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-03-02 11:27:02 +00:00
|
|
|
GET /index.txt HTTP/1.0
|
|
|
|
Accept-Encoding: gzip, deflate
|
|
|
|
EOF
|
|
|
|
);
|
2005-08-31 12:55:44 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '' } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'gzip, deflate - Content-Length and Content-Encoding is set');
|
2005-03-02 11:27:02 +00:00
|
|
|
|
2005-08-18 09:28:11 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
|
|
|
GET /index.txt HTTP/1.0
|
|
|
|
Accept-Encoding: gzip, deflate
|
|
|
|
EOF
|
|
|
|
);
|
2009-10-11 19:27:55 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
|
2005-08-18 09:28:11 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'Content-Type is from the original file');
|
|
|
|
|
2006-02-01 11:35:08 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
|
|
|
GET /index.txt HTTP/1.0
|
|
|
|
Accept-encoding:
|
|
|
|
X-Accept-encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0
|
|
|
|
User-Agent: MYOB/6.66 (AN/ON)
|
|
|
|
Connection: close
|
|
|
|
EOF
|
|
|
|
);
|
2009-10-11 19:27:55 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Type' => "text/plain; charset=utf-8" } ];
|
2006-02-01 11:35:08 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'Empty Accept-Encoding');
|
|
|
|
|
2008-10-03 10:05:33 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
|
|
|
GET /index.txt HTTP/1.0
|
|
|
|
Accept-Encoding: bzip2, gzip, deflate
|
|
|
|
Host: cache.example.org
|
|
|
|
EOF
|
|
|
|
);
|
2009-10-11 19:27:55 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Encoding' => 'gzip', 'Content-Type' => "text/plain; charset=utf-8" } ];
|
2008-10-03 10:05:33 +00:00
|
|
|
ok($tf->handle_http($t) == 0, 'bzip2 requested but disabled');
|
|
|
|
|
2006-02-01 11:35:08 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf->stop_proc == 0, "Stopping lighttpd");
|