From: Christian Walde Date: Thu, 5 Jul 2012 11:10:19 +0000 (+0200) Subject: fixed CGI detection under mod_cgid X-Git-Tag: v0.017~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b930ebb30cddbb0133a0ad20e72d60a5eed5d19;hp=fd6d986e8e58e27ba8c5139af099e89719a0ff35;p=catagits%2FWeb-Simple.git fixed CGI detection under mod_cgid The Apache module mod_cgid is default in modern Apaches with multi-threaded MPM and opens STDIN as a Socket, so interpreting that fact to mean that we're under FastCGI works ONLY if $ENV{GATEWAY_INTERFACE} is not set. See: http://httpd.apache.org/docs/2.0/mod/mod_cgid.html Exception: Some nginx FastCGI configuration examples (probably as a result of copy/paste) instruct the user to set: $ENV{GATEWAY_INTERFACE} = "CGI 1.1" If anyone actually did that, FastCGI would be wrongly recognized as CGI in their case. See: http://wiki.nginx.org/FcgiExample --- diff --git a/lib/Web/Simple/Application.pm b/lib/Web/Simple/Application.pm index dbba703..24d3463 100644 --- a/lib/Web/Simple/Application.pm +++ b/lib/Web/Simple/Application.pm @@ -87,7 +87,8 @@ sub run { my $self = shift; if ( $ENV{PHP_FCGI_CHILDREN} || $ENV{FCGI_ROLE} || $ENV{FCGI_SOCKET_PATH} - || -S STDIN # STDIN is a socket, almost certainly FastCGI + || ( -S STDIN && !$ENV{GATEWAY_INTERFACE} ) + # If STDIN is a socket, almost certainly FastCGI, except for mod_cgid ) { return $self->_run_fcgi; } elsif ($ENV{GATEWAY_INTERFACE}) {