~ubuntu-branches/ubuntu/edgy/lighttpd/edgy-security

« back to all changes in this revision

Viewing changes to tests/cachable.t

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-10-10 13:57:38 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061010135738-gn4pp1ut1s1g27pb
Tags: 1.4.13~r1370-1ubuntu1
* Merge from Debian unstable (Closes: Malone #64900). Remaining changes:
  - Add an additional dependency on libterm-readline-perl-perl
    (Malone #43895)

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 => 12;
 
12
use LightyTest;
 
13
 
 
14
my $tf = LightyTest->new();
 
15
my $t;
 
16
 
 
17
$tf->{CONFIGFILE} = 'lighttpd.conf';
 
18
    
 
19
ok($tf->start_proc == 0, "Starting lighttpd") or die();
 
20
 
 
21
## check if If-Modified-Since, If-None-Match works
 
22
 
 
23
$t->{REQUEST}  = ( <<EOF
 
24
GET / HTTP/1.0
 
25
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT
 
26
EOF
 
27
 );
 
28
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
 
29
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since');
 
30
 
 
31
$t->{REQUEST}  = ( <<EOF
 
32
GET / HTTP/1.0
 
33
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
 
34
EOF
 
35
 );
 
36
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Last-Modified' => ''} ];
 
37
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-Modified-Since, comment');
 
38
 
 
39
my $now = $t->{date};
 
40
 
 
41
$t->{REQUEST}  = ( <<EOF
 
42
GET / HTTP/1.0
 
43
If-Modified-Since: $now
 
44
EOF
 
45
 );
 
46
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
 
47
ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since');
 
48
 
 
49
$t->{REQUEST}  = ( <<EOF
 
50
GET / HTTP/1.0
 
51
If-Modified-Since: $now; foo
 
52
EOF
 
53
 );
 
54
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
 
55
ok($tf->handle_http($t) == 0, 'Conditional GET - new If-Modified-Since, comment');
 
56
 
 
57
$t->{REQUEST}  = ( <<EOF
 
58
GET / HTTP/1.0
 
59
If-None-Match: foo
 
60
EOF
 
61
 );
 
62
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+ETag' => ''} ];
 
63
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
 
64
 
 
65
my $etag = $t->{etag};
 
66
 
 
67
$t->{REQUEST}  = ( <<EOF
 
68
GET / HTTP/1.0
 
69
If-None-Match: $etag
 
70
EOF
 
71
 );
 
72
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
 
73
ok($tf->handle_http($t) == 0, 'Conditional GET - old If-None-Match');
 
74
 
 
75
$t->{REQUEST}  = ( <<EOF
 
76
GET / HTTP/1.0
 
77
If-None-Match: $etag
 
78
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
 
79
EOF
 
80
 );
 
81
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
 
82
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + old Last-Modified');
 
83
 
 
84
$t->{REQUEST}  = ( <<EOF
 
85
GET / HTTP/1.0
 
86
If-None-Match: $etag
 
87
If-Modified-Since: $now; foo
 
88
EOF
 
89
 );
 
90
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
 
91
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag, Last-Modified + comment');
 
92
 
 
93
$t->{REQUEST}  = ( <<EOF
 
94
GET / HTTP/1.0
 
95
If-None-Match: Foo
 
96
If-Modified-Since: Sun, 01 Jan 1970 00:00:01 GMT; foo
 
97
EOF
 
98
 );
 
99
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
 
100
ok($tf->handle_http($t) == 0, 'Conditional GET - old ETAG + old Last-Modified');
 
101
 
 
102
$t->{REQUEST}  = ( <<EOF
 
103
GET / HTTP/1.0
 
104
If-None-Match: $etag
 
105
If-Modified-Since: $now foo
 
106
EOF
 
107
 );
 
108
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 412 } ];
 
109
ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + Last-Modified + overlong timestamp');
 
110
 
 
111
ok($tf->stop_proc == 0, "Stopping lighttpd");
 
112