From: Tomas Doran Date: Wed, 16 Nov 2011 13:13:11 +0000 (+0000) Subject: Only apply the lighttpd middleware if needed X-Git-Tag: 5.90007~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1ce9c7f6a57e3d3ce511d87eb68c6a66ce9d96be Only apply the lighttpd middleware if needed --- diff --git a/Changes b/Changes index 40c4df8..93a96bd 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ # This file documents the revision history for Perl extension Catalyst. + Bug fixes: + - Lighttpd script name fix is only applied for lighttpd versions + < 1.4.23 + 5.90006 - 2011-10-25 09:18:00 New features: diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 71a5e56..2cdabed 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2743,7 +2743,16 @@ sub apply_default_middlewares { # If we're running under Lighttpd, swap PATH_INFO and SCRIPT_NAME # http://lists.scsys.co.uk/pipermail/catalyst/2006-June/008361.html - $psgi_app = Plack::Middleware::LighttpdScriptNameFix->wrap($psgi_app); + $psgi_app = Plack::Middleware::Conditional->wrap( + $psgi_app, + builder => sub { Plack::Middleware::LighttpdScriptNameFix->wrap($_[0]) }, + condition => sub { + my ($env) = @_; + return unless $env->{SERVER_SOFTWARE} && $env->{SERVER_SOFTWARE} =~ m!lighttpd[-/]1\.(\d+\.\d+)!; + return unless $env < 4.23; + 1; + }, + ); # we're applying this unconditionally as the middleware itself already makes # sure it doesn't fuck things up if it's not running under one of the right