[build_cmake] clock_gettime() -lrt w/ glibc < 2.17 (fixes #2737)
[lighttpd.git] / tests / mod-extforward.t
blob6722234f12e99c12e0456d1e58e4fceae0899fea
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;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 5;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 $tf->{CONFIGFILE} = 'mod-extforward.conf';
19 ok($tf->start_proc == 0, "Starting lighttpd") or die();
21 $t->{REQUEST} = ( <<EOF
22 GET /ip.pl HTTP/1.0
23 Host: www.example.org
24 X-Forwarded-For: 127.0.10.1
25 EOF
27 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.10.1' } ];
28 ok($tf->handle_http($t) == 0, 'expect 127.0.10.1, from single ip');
30 $t->{REQUEST} = ( <<EOF
31 GET /ip.pl HTTP/1.0
32 Host: www.example.org
33 X-Forwarded-For: 127.0.10.1, 127.0.20.1
34 EOF
36 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
37 ok($tf->handle_http($t) == 0, 'expect 127.0.20.1, from two ips');
39 $t->{REQUEST} = ( <<EOF
40 GET /ip.pl HTTP/1.0
41 Host: www.example.org
42 X-Forwarded-For: 127.0.10.1, 127.0.20.1, 127.0.30.1
43 EOF
45 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
46 ok($tf->handle_http($t) == 0, 'expect 127.0.20.1, from chained proxies');
48 ok($tf->stop_proc == 0, "Stopping lighttpd");