]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/HTTPD.pm
httpd: remove psgix.harakiri reference
[public-inbox.git] / lib / PublicInbox / HTTPD.pm
1 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 package PublicInbox::HTTPD;
5 use strict;
6 use warnings;
7 use Plack::Util;
8 require PublicInbox::HTTPD::Async;
9 require PublicInbox::Daemon;
10
11 sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) }
12
13 sub new {
14         my ($class, $sock, $app) = @_;
15         my $n = getsockname($sock) or die "not a socket: $sock $!\n";
16         my ($host, $port) = PublicInbox::Daemon::host_with_port($n);
17
18         my %env = (
19                 SERVER_NAME => $host,
20                 SERVER_PORT => $port,
21                 SCRIPT_NAME => '',
22                 'psgi.version' => [ 1, 1 ],
23                 'psgi.errors' => \*STDERR,
24                 'psgi.url_scheme' => 'http',
25                 'psgi.nonblocking' => Plack::Util::TRUE,
26                 'psgi.streaming' => Plack::Util::TRUE,
27                 'psgi.run_once'  => Plack::Util::FALSE,
28                 'psgi.multithread' => Plack::Util::FALSE,
29                 'psgi.multiprocess' => Plack::Util::TRUE,
30                 'psgix.input.buffered' => Plack::Util::TRUE,
31
32                 # XXX unstable API!
33                 'pi-httpd.async' => do {
34                         no warnings 'once';
35                         *pi_httpd_async
36                 },
37         );
38         bless {
39                 app => $app,
40                 env => \%env
41         }, $class;
42 }
43
44 1;