Annotation of embedaddon/lighttpd/tests/mod-compress.t, revision 1.1
1.1 ! misho 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;
! 7: }
! 8:
! 9: use strict;
! 10: use IO::Socket;
! 11: use Test::More tests => 11;
! 12: use LightyTest;
! 13:
! 14: my $tf = LightyTest->new();
! 15: my $t;
! 16:
! 17: $tf->{CONFIGFILE} = 'mod-compress.conf';
! 18:
! 19: ok($tf->start_proc == 0, "Starting lighttpd") or die();
! 20:
! 21: $t->{REQUEST} = ( <<EOF
! 22: GET /index.html HTTP/1.0
! 23: Accept-Encoding: deflate
! 24: EOF
! 25: );
! 26: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '' } ];
! 27: ok($tf->handle_http($t) == 0, 'Vary is set');
! 28:
! 29: $t->{REQUEST} = ( <<EOF
! 30: GET /index.html HTTP/1.0
! 31: Accept-Encoding: deflate
! 32: Host: no-cache.example.org
! 33: EOF
! 34: );
! 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');
! 37:
! 38: $t->{REQUEST} = ( <<EOF
! 39: GET /index.html HTTP/1.0
! 40: Accept-Encoding: deflate
! 41: Host: cache.example.org
! 42: EOF
! 43: );
! 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');
! 46:
! 47: $t->{REQUEST} = ( <<EOF
! 48: GET /index.html HTTP/1.0
! 49: Accept-Encoding: gzip
! 50: Host: no-cache.example.org
! 51: EOF
! 52: );
! 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');
! 55:
! 56: $t->{REQUEST} = ( <<EOF
! 57: GET /index.html HTTP/1.0
! 58: Accept-Encoding: gzip
! 59: Host: cache.example.org
! 60: EOF
! 61: );
! 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');
! 64:
! 65:
! 66: $t->{REQUEST} = ( <<EOF
! 67: GET /index.txt HTTP/1.0
! 68: Accept-Encoding: gzip, deflate
! 69: EOF
! 70: );
! 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');
! 73:
! 74: $t->{REQUEST} = ( <<EOF
! 75: GET /index.txt HTTP/1.0
! 76: Accept-Encoding: gzip, deflate
! 77: EOF
! 78: );
! 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');
! 81:
! 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
! 89: );
! 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');
! 92:
! 93: $t->{REQUEST} = ( <<EOF
! 94: GET /index.txt HTTP/1.0
! 95: Accept-Encoding: bzip2, gzip, deflate
! 96: Host: cache.example.org
! 97: EOF
! 98: );
! 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');
! 101:
! 102:
! 103: ok($tf->stop_proc == 0, "Stopping lighttpd");
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>