about summary refs log tree commit homepage
path: root/t/httpd-corner.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-07 23:05:13 -1000
committerEric Wong <e@80x24.org>2021-02-08 22:07:43 +0000
commit860169adcd29341142b7c4a369c09b4ac492bd1e (patch)
treef08dcf8bd04efaeb0904a6cec40665c107482cac /t/httpd-corner.t
parentfb6aa4da304125a3fb7932e1335be85ff260e031 (diff)
downloadpublic-inbox-860169adcd29341142b7c4a369c09b4ac492bd1e.tar.gz
IPv4 gets plenty of real-world coverage, and apparently there's
Debian buildd hosts which lack IPv4(*).  So ensure everything
can work on IPv6 and not cause problems for odd setups.

(*) https://bugs.debian.org/979432
Diffstat (limited to 't/httpd-corner.t')
-rw-r--r--t/httpd-corner.t12
1 files changed, 5 insertions, 7 deletions
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index c3f80530..794d8aeb 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -11,7 +11,6 @@ use PublicInbox::TestCommon;
 require_mods(qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status));
 use Digest::SHA qw(sha1_hex);
 use IO::Handle ();
-use IO::Socket;
 use IO::Socket::UNIX;
 use Fcntl qw(:seek);
 use Socket qw(IPPROTO_TCP TCP_NODELAY SOL_SOCKET);
@@ -50,14 +49,13 @@ sub unix_server ($) {
                 Listen => 1024,
                 Type => Socket::SOCK_STREAM(),
                 Local => $_[0],
-        );
+        ) or BAIL_OUT "bind + listen $_[0]: $!";
         $s->blocking(0);
         $s;
 }
 
 my $upath = "$tmpdir/s";
 my $unix = unix_server($upath);
-ok($unix, 'UNIX socket created');
 my $td;
 my $spawn_httpd = sub {
         my (@args) = @_;
@@ -219,7 +217,7 @@ sub check_400 {
         ok($u, 'unix socket connected');
         $u->write("GET /host-port HTTP/1.0\r\n\r\n");
         $u->read(my $buf, 4096);
-        like($buf, qr!\r\n\r\n127\.0\.0\.1:0\z!,
+        like($buf, qr!\r\n\r\n127\.0\.0\.1 0\z!,
                 'set REMOTE_ADDR and REMOTE_PORT for Unix socket');
 }
 
@@ -236,8 +234,8 @@ sub conn_for {
         $conn->write("GET /host-port HTTP/1.0\r\n\r\n");
         $conn->read(my $buf, 4096);
         my ($head, $body) = split(/\r\n\r\n/, $buf);
-        my ($addr, $port) = split(/:/, $body);
-        is($addr, $conn->sockhost, 'host matches addr');
+        my ($addr, $port) = split(/ /, $body);
+        is($addr, (tcp_host_port($conn))[0], 'host matches addr');
         is($port, $conn->sockport, 'port matches');
 }
 
@@ -306,7 +304,7 @@ my $check_self = sub {
 
 SKIP: {
         my $curl = which('curl') or skip('curl(1) missing', 4);
-        my $base = 'http://' . $sock->sockhost . ':' . $sock->sockport;
+        my $base = 'http://'.tcp_host_port($sock);
         my $url = "$base/sha1";
         my ($r, $w);
         pipe($r, $w) or die "pipe: $!";