Only apply the lighttpd middleware if needed
Tomas Doran [Wed, 16 Nov 2011 13:13:11 +0000 (13:13 +0000)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index 40c4df8..93a96bd 100644 (file)
--- 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:
index 71a5e56..2cdabed 100644 (file)
@@ -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