2 # Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
6 require PublicInbox::WWW;
10 $NO_SCRIPT_NAME = 1 if $ENV{NO_SCRIPT_NAME};
11 CGI->compile if $ENV{MOD_PERL};
14 # some servers (Ruby webrick) include scheme://host[:port] here,
15 # which confuses CGI.pm when generating self_url.
16 # RFC 3875 does not mention REQUEST_URI at all,
17 # so nuke it since CGI.pm functions without it.
18 delete $ENV{REQUEST_URI};
19 $ENV{SCRIPT_NAME} = '' if $NO_SCRIPT_NAME;
21 my $ret = PublicInbox::WWW::run($req, $req->request_method);
23 if (@ARGV && $ARGV[0] eq 'static') {
24 print $ret->[2]->[0]; # only show the body
26 my ($status, $headers, $body) = @$ret;
29 301 => 'Moved Permanently',
31 405 => 'Method Not Allowed',
32 501 => 'Not Implemented',
35 print "Status: $status $codes{$status}\r\n";
37 while (my ($k, $v) = splice(@tmp, 0, 2)) {
40 print "\r\n", $body->[0];