replace 'localhost' by gethostbyaddr for 127.0.0.1

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@669 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.3
Jan Kneschke 2005-09-01 11:12:05 +00:00
parent 8e742eac4c
commit a44e7fc4c4
4 changed files with 13 additions and 8 deletions

View File

@ -4,6 +4,7 @@ package LightyTest;
use strict;
use IO::Socket;
use Test::More;
use Socket;
use Cwd 'abs_path';
sub new {
@ -27,7 +28,11 @@ sub new {
$self->{LIGHTTPD_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid';
$self->{PIDOF_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/pidof.pid';
$self->{PORT} = 2048;
my ($name, $aliases, $addrtype, $net) = gethostbyaddr(inet_aton("127.0.0.1"), AF_INET);
$self->{HOSTNAME} = $name;
bless($self, $class);
return $self;

View File

@ -77,14 +77,14 @@ $t->{REQUEST} = ( <<EOF
GET /dummydir HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/dummydir/' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/dummydir/' } ];
ok($tf->handle_http($t) == 0, 'internal redirect in directory');
$t->{REQUEST} = ( <<EOF
GET /dummydir?foo HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/dummydir/?foo' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/dummydir/?foo' } ];
ok($tf->handle_http($t) == 0, 'internal redirect in directory + querystring');
## simple-vhost

View File

@ -21,7 +21,7 @@ GET /redirect/ HTTP/1.0
Host: vvv.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/' } ];
ok($tf->handle_http($t) == 0, 'external redirect');
$t->{REQUEST} = ( <<EOF
@ -29,7 +29,7 @@ GET /redirect/ HTTP/1.0
Host: zzz.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/zzz' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/zzz' } ];
ok($tf->handle_http($t) == 0, 'external redirect with cond regsub');
$t->{REQUEST} = ( <<EOF
@ -37,7 +37,7 @@ GET /redirect/ HTTP/1.0
Host: remoteip.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/127.0.0.1' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/127.0.0.1' } ];
ok($tf->handle_http($t) == 0, 'external redirect with cond regsub on remoteip');
$t->{REQUEST} = ( <<EOF
@ -45,7 +45,7 @@ GET /redirect/ HTTP/1.0
Host: remoteip2.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/remoteip2' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/remoteip2' } ];
ok($tf->handle_http($t) == 0, 'external redirect with cond regsub on remoteip2');
ok($tf->stop_proc == 0, "Stopping lighttpd");

View File

@ -29,7 +29,7 @@ $t->{REQUEST} = ( <<EOF
GET /~jan HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://localhost:2048/~jan/' } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => 'http://'.$tf->{HOSTNAME}.':'.$tf->{PORT}.'/~jan/' } ];
ok($tf->handle_http($t) == 0, 'valid user + redirect');
$t->{REQUEST} = ( <<EOF