~ubuntu-branches/ubuntu/natty/lighttpd/natty

« back to all changes in this revision

Viewing changes to tests/mod-compress.t

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Marek
  • Date: 2005-11-26 11:48:51 UTC
  • Revision ID: james.westby@ubuntu.com-20051126114851-76t9q0rrwbzjnt2t
Tags: upstream-1.4.8
ImportĀ upstreamĀ versionĀ 1.4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 => 9;
 
12
use LightyTest;
 
13
 
 
14
my $tf = LightyTest->new();
 
15
my $t;
 
16
    
 
17
ok($tf->start_proc == 0, "Starting lighttpd") or die();
 
18
 
 
19
$t->{REQUEST}  = ( <<EOF
 
20
GET /index.html HTTP/1.0
 
21
Accept-Encoding: deflate
 
22
EOF
 
23
 );
 
24
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '' } ];
 
25
ok($tf->handle_http($t) == 0, 'Vary is set');
 
26
 
 
27
$t->{REQUEST}  = ( <<EOF
 
28
GET /index.html HTTP/1.0
 
29
Accept-Encoding: deflate
 
30
Host: no-cache.example.org
 
31
EOF
 
32
 );
 
33
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ];
 
34
ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
 
35
 
 
36
$t->{REQUEST}  = ( <<EOF
 
37
GET /index.html HTTP/1.0
 
38
Accept-Encoding: deflate
 
39
Host: cache.example.org
 
40
EOF
 
41
 );
 
42
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1288', '+Content-Encoding' => '' } ];
 
43
ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
 
44
 
 
45
$t->{REQUEST}  = ( <<EOF
 
46
GET /index.html HTTP/1.0
 
47
Accept-Encoding: gzip
 
48
Host: no-cache.example.org
 
49
EOF
 
50
 );
 
51
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ];
 
52
ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
 
53
 
 
54
$t->{REQUEST}  = ( <<EOF
 
55
GET /index.html HTTP/1.0
 
56
Accept-Encoding: gzip
 
57
Host: cache.example.org
 
58
EOF
 
59
 );
 
60
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => '1306', '+Content-Encoding' => '' } ];
 
61
ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
 
62
 
 
63
 
 
64
$t->{REQUEST}  = ( <<EOF
 
65
GET /index.txt HTTP/1.0
 
66
Accept-Encoding: gzip, deflate
 
67
EOF
 
68
 );
 
69
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '' } ];
 
70
ok($tf->handle_http($t) == 0, 'gzip, deflate - Content-Length and Content-Encoding is set');
 
71
 
 
72
$t->{REQUEST}  = ( <<EOF
 
73
GET /index.txt HTTP/1.0
 
74
Accept-Encoding: gzip, deflate
 
75
EOF
 
76
 );
 
77
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '+Content-Encoding' => '', 'Content-Type' => "text/plain" } ];
 
78
ok($tf->handle_http($t) == 0, 'Content-Type is from the original file');
 
79
 
 
80
ok($tf->stop_proc == 0, "Stopping lighttpd");