X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=public-inbox.cgi;h=157cf6a200e8b060d36f4477b14a3728be29d20a;hb=f76f265a851944b5dedcc3be5f3b5224b6ebda89;hp=5c6dfe8a3c5a298ba3b7f4591c4dce0223b041b8;hpb=f71e9e9b67a6ff23642ccd119390bd6b3cb0d91e;p=public-inbox.git diff --git a/public-inbox.cgi b/public-inbox.cgi index 5c6dfe8a..157cf6a2 100755 --- a/public-inbox.cgi +++ b/public-inbox.cgi @@ -1,20 +1,25 @@ #!/usr/bin/perl -w -# Copyright (C) 2014, Eric Wong and all contributors +# Copyright (C) 2014-2015 all contributors # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) use strict; use warnings; use IO::Handle; -require PublicInbox::WWW; +use PublicInbox::WWW; use CGI qw/-nosticky/; our $NO_SCRIPT_NAME; our %HTTP_CODES; BEGIN { $NO_SCRIPT_NAME = 1 if $ENV{NO_SCRIPT_NAME}; - CGI->compile if $ENV{MOD_PERL}; + if ($ENV{MOD_PERL}) { + CGI->compile; + PublicInbox::WWW->preload; + } %HTTP_CODES = ( 200 => 'OK', + 300 => 'Multiple Choices', 301 => 'Moved Permanently', + 302 => 'Found', 404 => 'Not Found', 405 => 'Method Not Allowed', 501 => 'Not Implemented', @@ -32,16 +37,13 @@ my $ret = PublicInbox::WWW::run($req, $req->request_method); my $out = select; $out->binmode; -if (@ARGV && $ARGV[0] eq 'static') { - $out->write($ret->[2]->[0]); # only show the body -} else { # CGI - if (ref($ret) eq 'CODE') { - $ret->(*dump_header); - } else { - my ($status, $headers, $body) = @$ret; - dump_header([$status, $headers])->write($body->[0]); - } +if (ref($ret) eq 'CODE') { + $ret->(*dump_header); +} else { + my ($status, $headers, $body) = @$ret; + + dump_header([$status, $headers])->write($body->[0]); } sub dump_header {