Skip to content

Commit

Permalink
set 127.0.0.1 or [::1] explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Aug 4, 2019
1 parent c60cf1c commit af26803
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 1 addition & 5 deletions t/local/LocalServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ sub spawn {
die "Couldn't read back local server url"
unless $url;

# What is this code supposed to fix?
my $lhurl = URI::URL->new( $url );
$lhurl->host( 'localhost' );
$self->{_server_url} = $lhurl;

$self->{_server_url} = URI::URL->new($url);
$self->{_fh} = $server;
$self->{_pid} = $pid;

Expand Down
18 changes: 10 additions & 8 deletions t/local/log-server
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ use strict;
use HTTP::Daemon 6.05;
use CGI 4.08;
use Getopt::Long;
use Socket ();

$|++;

GetOptions(
'e=s' => \my $expression,
);

my $host = 'localhost';
my $d = HTTP::Daemon->new(
LocalAddr => $host,
) or die;
my $d = HTTP::Daemon->new or die;

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

my ($filename,$logfile) = @ARGV[0,1];
Expand Down
9 changes: 8 additions & 1 deletion t/local/referer-server
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

use HTTP::Daemon 6.05;
use URI::URL;
use Socket ();

$|++;

my $d = HTTP::Daemon->new or die;
my $lhurl = URI::URL->new( $d->url );
$lhurl->host( 'localhost' );
if ($d->sockdomain == Socket::AF_INET) {
$lhurl->host( '127.0.0.1' );
} elsif ($d->sockdomain == Socket::AF_INET6) {
$lhurl->host( '[::1]' );
} else {
die "unexpected sockdomain: " . $d->sockdomain;
}
print $lhurl->as_string, "\n";

$counter = 5;
Expand Down

0 comments on commit af26803

Please sign in to comment.