1 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # wraps a listen socket for HTTP and links it to the PSGI app in
6 package PublicInbox::HTTPD;
10 use PublicInbox::HTTPD::Async;
11 use PublicInbox::Daemon;
13 sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) }
16 my ($class, $sock, $app) = @_;
17 my $n = getsockname($sock) or die "not a socket: $sock $!\n";
18 my ($host, $port) = PublicInbox::Daemon::host_with_port($n);
24 'psgi.version' => [ 1, 1 ],
25 'psgi.errors' => \*STDERR,
26 'psgi.url_scheme' => 'http',
27 'psgi.nonblocking' => Plack::Util::TRUE,
28 'psgi.streaming' => Plack::Util::TRUE,
29 'psgi.run_once' => Plack::Util::FALSE,
30 'psgi.multithread' => Plack::Util::FALSE,
31 'psgi.multiprocess' => Plack::Util::TRUE,
33 # We don't use this anywhere, but we can support
34 # other PSGI apps which might use it:
35 'psgix.input.buffered' => Plack::Util::TRUE,
37 # XXX unstable API!, only GitHTTPBackend needs
38 # this to limit git-http-backend(1) parallelism.
39 # The rest of our PSGI code is generic, relying
40 # on "pull" model using "getline" to prevent
42 'pi-httpd.async' => \&pi_httpd_async