Properly work around lighttpd PATH_INFO vs. SCRIPT_NAME bug (thanks to Mark Blythe)
Andy Grundman [Sat, 21 Oct 2006 02:30:59 +0000 (02:30 +0000)]
Changes
lib/Catalyst/Engine/FastCGI.pm

diff --git a/Changes b/Changes
index 80f6b92..df1f570 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
 This file documents the revision history for Perl extension Catalyst.
 
 ?        ?
+       - Properly work around lighttpd PATH_INFO vs. SCRIPT_NAME bug.
+         (Mark Blythe)
        - add _application accessor
        - Support current_view
        - Allow use Catalyst::Test without app name (Ton Voon, Altinity)
index ba182d3..9bc918e 100644 (file)
@@ -101,7 +101,16 @@ sub run {
 
     while ( $request->Accept >= 0 ) {
         $proc_manager && $proc_manager->pm_pre_dispatch();
+        
+        # If we're running under Lighttpd, swap PATH_INFO and SCRIPT_NAME
+        # http://lists.rawmode.org/pipermail/catalyst/2006-June/008361.html
+        # Thanks to Mark Blythe for this fix
+        if ( $env{SERVER_SOFTWARE} && $env{SERVER_SOFTWARE} =~ /lighttpd/ ) {
+            $env{PATH_INFO} = delete $env{SCRIPT_NAME};
+        }
+        
         $class->handle_request( env => \%env );
+        
         $proc_manager && $proc_manager->pm_post_dispatch();
     }
 }