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 /script/public-inbox-httpd | |
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 'script/public-inbox-httpd')
-rwxr-xr-x | script/public-inbox-httpd | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd index d867b477..b6c4e677 100755 --- a/script/public-inbox-httpd +++ b/script/public-inbox-httpd @@ -99,18 +99,10 @@ sub pi_httpd_async { sub new { my ($class, $sock, $app) = @_; my $n = getsockname($sock) or die "not a socket: $sock $!\n"; - my ($port, $addr); - if (length($n) >= 28) { - require Socket6; - ($port, $addr) = Socket6::unpack_sockaddr_in6($n); - } else { - ($port, $addr) = Socket::unpack_sockaddr_in($n); - } + my ($host, $port) = PublicInbox::Daemon::host_with_port($n); my %env = ( - REMOTE_HOST => '', - REMOTE_PORT => 0, - SERVER_NAME => $addr, + SERVER_NAME => $host, SERVER_PORT => $port, SCRIPT_NAME => '', 'psgi.version' => [ 1, 1 ], |