]> Sergey Matveev's repositories - public-inbox.git/commitdiff
cgi: make CGI optional for Plack users
authorEric Wong <e@80x24.org>
Mon, 28 Apr 2014 22:09:30 +0000 (22:09 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Apr 2014 22:09:30 +0000 (22:09 +0000)
CGI.pm is on its way out, so do not make it a hard requirement for
Plack users.  We still support CGI-only installations because some
sysadmins and distros may be very conservative.

public-inbox.cgi

index 54ff0159efb92fdb3232da60e8c5a4917de46664..9314712431a54da4c8a345c741ff9c8e13bd59b9 100755 (executable)
@@ -12,7 +12,6 @@
 use 5.008;
 use strict;
 use warnings;
-use CGI qw(:cgi -nosticky); # PSGI/FastCGI/mod_perl compat
 use PublicInbox::Config;
 use URI::Escape qw(uri_escape_utf8 uri_unescape);
 our $LISTNAME_RE = qr!\A/([\w\.\-]+)!;
@@ -21,6 +20,8 @@ BEGIN {
        $pi_config = PublicInbox::Config->new;
        # TODO: detect and reload config as needed
        if ($ENV{MOD_PERL}) {
+               require CGI;
+               $CGI::NOSTICKY = 1;
                CGI->compile;
        }
 }
@@ -32,6 +33,7 @@ if ($ENV{PI_PLACKUP}) {
        # which confuses CGI.pm when generating self_url.
        # RFC 3875 does not mention REQUEST_URI at all,
        # so nuke it since CGI.pm functions without it.
+       require CGI;
        delete $ENV{REQUEST_URI};
        my $req = CGI->new;
        my $ret = main($req, $req->request_method);