Annotation of embedaddon/lighttpd/tests/cachable.t, revision 1.1.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 => 13;
                     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' => 304 } ];
                     82: ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + old Last-Modified (which should be ignored)');
                     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 (which should be ignored)');
                     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' => 304 } ];
                    109: ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + Last-Modified + overlong timestamp (which should be ignored)');
                    110: 
                    111: $t->{REQUEST}  = ( <<EOF
                    112: GET / HTTP/1.0
                    113: If-None-Match: $etag
                    114: Host: etag.example.org
                    115: EOF
                    116:  );
                    117: $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
                    118: ok($tf->handle_http($t) == 0, 'Conditional GET - ETag + disabled etags on server side');
                    119: 
                    120: ok($tf->stop_proc == 0, "Stopping lighttpd");
                    121: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>