#
# Standalone HTTP server for public-inbox.
use strict;
+use v5.10.1;
use PublicInbox::Daemon;
BEGIN {
for (qw(Plack::Builder Plack::Util)) {
require PublicInbox::HTTPD;
}
-my %httpds;
+my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_<NAME|PORT>}
my $app;
my $refresh = sub {
if (@ARGV) {
sub { $www->call(@_) };
};
}
+ %httpds = (); # invalidate cache
};
PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
- sub ($$$) { # post_accept
- my ($client, $addr, $srv) = @_;
+ sub ($$$) { # Listener->{post_accept}
+ my ($client, $addr, $srv, $tls_wrap) = @_;
my $fd = fileno($srv);
- my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
+ my $h = $httpds{$fd} //=
+ PublicInbox::HTTPD->new($srv, $app, $client);
PublicInbox::HTTP->new($client, $addr, $h),
});