diff options
author | Eric Wong <e@80x24.org> | 2016-03-03 05:14:31 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-03-03 09:19:16 +0000 |
commit | b38de6f02fa04e36b881d2aad9c7f792beb0b6a1 (patch) | |
tree | f0d6f21a534a7da7ac29a0a082921cf1d0566e14 /t | |
parent | b8e30717b529d6461190b54efa8c6402197cdd4e (diff) | |
download | public-inbox-b38de6f02fa04e36b881d2aad9c7f792beb0b6a1.tar.gz |
This allows us to share more code between daemons and avoids having to make additional syscalls for preparing REMOTE_HOST and REMOTE_PORT in the PSGI env in -httpd. This will also make supporting HTTP (and NNTP) over Unix sockets easier in a future commit.
Diffstat (limited to 't')
-rw-r--r-- | t/httpd-corner.psgi | 3 | ||||
-rw-r--r-- | t/httpd-corner.t | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi index c3bf5231..349b35df 100644 --- a/t/httpd-corner.psgi +++ b/t/httpd-corner.psgi @@ -44,6 +44,9 @@ my $app = sub { $fh->close; }; } + } elsif ($path eq '/host-port') { + $code = 200; + push @$body, "$env->{REMOTE_ADDR}:$env->{REMOTE_PORT}"; } [ $code, $h, $body ] diff --git a/t/httpd-corner.t b/t/httpd-corner.t index e73ebd5e..198a7e90 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -76,6 +76,16 @@ sub conn_for { return $conn; } +{ + my $conn = conn_for($sock, 'host-port'); + $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'); + is($port, $conn->sockport, 'port matches'); +} + # graceful termination { my $conn = conn_for($sock, 'graceful termination via slow header'); |