Skip to content

Commit 4173118

Browse files
skajioalders
authored andcommitted
set 127.0.0.1 or [::1] explicitly
1 parent 0e70759 commit 4173118

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

t/local/LocalServer.pm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ sub spawn {
113113
die "Couldn't read back local server url"
114114
unless $url;
115115

116-
# What is this code supposed to fix?
117-
my $lhurl = URI::URL->new( $url );
118-
$lhurl->host( 'localhost' );
119-
$self->{_server_url} = $lhurl;
120-
116+
$self->{_server_url} = URI::URL->new($url);
121117
$self->{_fh} = $server;
122118
$self->{_pid} = $pid;
123119

t/local/log-server

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ use strict;
33
use HTTP::Daemon 6.05;
44
use CGI 4.08;
55
use Getopt::Long;
6+
use Socket ();
67

78
$|++;
89

910
GetOptions(
1011
'e=s' => \my $expression,
1112
);
1213

13-
my $host = 'localhost';
14-
my $d = HTTP::Daemon->new(
15-
LocalAddr => $host,
16-
) or die;
14+
my $d = HTTP::Daemon->new or die;
1715

18-
# HTTP::Deamon doesn't return http://localhost:.../
19-
# for LocalAddr => 'localhost'. This causes the
20-
# tests to fail of many machines.
21-
( my $url = URI->new($d->url) )->host($host);
16+
my $url = URI->new($d->url);
17+
if ($d->sockdomain == Socket::AF_INET) {
18+
$url->host( '127.0.0.1' );
19+
} elsif ($d->sockdomain == Socket::AF_INET6) {
20+
$url->host( '[::1]' );
21+
} else {
22+
die "unexpected sockdomain: " . $d->sockdomain;
23+
}
2224
print "$url\n";
2325

2426
my ($filename,$logfile) = @ARGV[0,1];

t/local/referer-server

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
use HTTP::Daemon 6.05;
44
use URI::URL;
5+
use Socket ();
56

67
$|++;
78

89
my $d = HTTP::Daemon->new or die;
910
my $lhurl = URI::URL->new( $d->url );
10-
$lhurl->host( 'localhost' );
11+
if ($d->sockdomain == Socket::AF_INET) {
12+
$lhurl->host( '127.0.0.1' );
13+
} elsif ($d->sockdomain == Socket::AF_INET6) {
14+
$lhurl->host( '[::1]' );
15+
} else {
16+
die "unexpected sockdomain: " . $d->sockdomain;
17+
}
1118
print $lhurl->as_string, "\n";
1219

1320
$counter = 5;

0 commit comments

Comments
 (0)