[Catalyst-commits] r7624 - in Catalyst-Runtime/5.80/branches/moose: . lib lib/Catalyst lib/Catalyst/Engine t t/conf t/something t/something/script t/something/script/foo

marcus at dev.catalyst.perl.org marcus at dev.catalyst.perl.org
Tue Apr 22 20:51:48 BST 2008


Author: marcus
Date: 2008-04-22 20:51:48 +0100 (Tue, 22 Apr 2008)
New Revision: 7624

Added:
   Catalyst-Runtime/5.80/branches/moose/t/live_engine_request_auth.t
   Catalyst-Runtime/5.80/branches/moose/t/something/
   Catalyst-Runtime/5.80/branches/moose/t/something/Makefile.PL
   Catalyst-Runtime/5.80/branches/moose/t/something/script/
   Catalyst-Runtime/5.80/branches/moose/t/something/script/foo/
   Catalyst-Runtime/5.80/branches/moose/t/something/script/foo/bar/
   Catalyst-Runtime/5.80/branches/moose/t/unit_utils_subdir.t
Modified:
   Catalyst-Runtime/5.80/branches/moose/
   Catalyst-Runtime/5.80/branches/moose/Changes
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst.pm
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/FastCGI.pm
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/HTTP.pm
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Runtime.pm
   Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Utils.pm
   Catalyst-Runtime/5.80/branches/moose/t/conf/extra.conf.in
Log:
 r19759 at command-central (orig r7584):  matthewt | 2008-04-07 15:47:07 +0200
  r17518 at agaton (orig r7490):  andyg | 2008-03-12 16:09:16 +0000
  Add a test and update docs on how to pass-through the Authorization header under Apache mod_fastcgi/mod_cgi
  r17803 at agaton (orig r7560):  andyg | 2008-04-04 17:08:19 +0100
  Patch from Ton Voon to fix bug in HTTP engine where the connection was not closed properly if the client disconnected before sending any headers
  r17804 at agaton (orig r7561):  andyg | 2008-04-04 17:09:50 +0100
  Gah, breaking my own line-length rules
  r17819 at agaton (orig r7576):  marcus | 2008-04-06 20:42:48 +0100
  Patch to fix homefinding for scripts in deep subdirs
 



Property changes on: Catalyst-Runtime/5.80/branches/moose
___________________________________________________________________
Name: svk:merge
   - 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7442
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
   + 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7576
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:7584
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442

Modified: Catalyst-Runtime/5.80/branches/moose/Changes
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/Changes	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/Changes	2008-04-22 19:51:48 UTC (rev 7624)
@@ -1,5 +1,12 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+5.7013
+        - Fix subdirs for scripts that run in subdirs more than one level deep.
+        - Added test and updated docs for handling the Authorization header
+          under mod_fastcgi/mod_cgi.
+        - Fixed bug in HTTP engine where the connection was not closed properly if the
+          client disconnected before sending any headers. (Ton Voon)
+
 5.7012  2007-12-16 23:44:00
         - Fix uri_for()'s and uri_with()'s handling of multibyte chars
           (Daisuke Murase)

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/FastCGI.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/FastCGI.pm	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/FastCGI.pm	2008-04-22 19:51:48 UTC (rev 7624)
@@ -325,6 +325,16 @@
 For more information on using FastCGI under Apache, visit
 L<http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html>
 
+=head3 Authorization header with mod_fastcgi or mod_cgi
+
+By default, mod_fastcgi/mod_cgi do not pass along the Authorization header,
+so modules like C<Catalyst::Plugin::Authentication::Credential::HTTP> will
+not work.  To enable pass-through of this header, add the following
+mod_rewrite directives:
+
+    RewriteCond %{HTTP:Authorization} ^(.+)
+    RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]
+
 =head2 Lighttpd
 
 These configurations were tested with Lighttpd 1.4.7.

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/HTTP.pm	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Engine/HTTP.pm	2008-04-22 19:51:48 UTC (rev 7624)
@@ -256,15 +256,16 @@
 
             if ( !$self->_read_headers ) {
                 # Error reading, give up
+                close Remote;
                 next LISTEN;
             }
 
             my ( $method, $uri, $protocol ) = $self->_parse_request_line;
-
+            
+            next unless $method;
+        
             DEBUG && warn "Parsed request: $method $uri $protocol\n";
 
-            next unless $method;
-
             unless ( uc($method) eq 'RESTART' ) {
 
                 # Fork
@@ -412,12 +413,17 @@
 
     while (1) {
         my $read = sysread Remote, my $buf, CHUNKSIZE;
-
-        if ( !$read ) {
-            DEBUG && warn "EOF or error: $!\n";
+        
+        if ( !defined $read ) {
+            next if $! == EWOULDBLOCK;
+            DEBUG && warn "Error reading headers: $!\n";
             return;
         }
-
+        elsif ( $read == 0 ) {
+            DEBUG && warn "EOF\n";
+            return;
+        }
+    
         DEBUG && warn "Read $read bytes\n";
         $self->{inputbuf} .= $buf;
         last if $self->{inputbuf} =~ /(\x0D\x0A?\x0D\x0A?|\x0A\x0D?\x0A\x0D?)/s;

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Runtime.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Runtime.pm	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Runtime.pm	2008-04-22 19:51:48 UTC (rev 7624)
@@ -7,7 +7,7 @@
 
 # Remember to update this in Catalyst as well!
 
-our $VERSION='5.7012';
+our $VERSION='5.7013';
 
 =head1 NAME
 

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Utils.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Utils.pm	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst/Utils.pm	2008-04-22 19:51:48 UTC (rev 7624)
@@ -171,8 +171,9 @@
                 # clean up relative path:
                 # MyApp/script/.. -> MyApp
 
-                my ($lastdir) = $home->dir_list( -1, 1 );
-                if ( $lastdir eq '..' ) {
+                my $dir;
+                my @dir_list = $home->dir_list();
+                while (($dir = pop(@dir_list)) && $dir eq '..') {
                     $home = dir($home)->parent->parent;
                 }
 

Modified: Catalyst-Runtime/5.80/branches/moose/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/lib/Catalyst.pm	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/lib/Catalyst.pm	2008-04-22 19:51:48 UTC (rev 7624)
@@ -73,7 +73,7 @@
 
 # Remember to update this in Catalyst::Runtime as well!
 
-our $VERSION = '5.7012';
+our $VERSION = '5.7013';
 
 sub import {
     my ( $class, @arguments ) = @_;

Modified: Catalyst-Runtime/5.80/branches/moose/t/conf/extra.conf.in
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/t/conf/extra.conf.in	2008-04-22 19:35:28 UTC (rev 7623)
+++ Catalyst-Runtime/5.80/branches/moose/t/conf/extra.conf.in	2008-04-22 19:51:48 UTC (rev 7624)
@@ -13,6 +13,10 @@
         # one CGI test will fail if you don't have mod_rewrite enabled
         RewriteEngine on
         RewriteRule /cgi$ /cgi/ [PT]
+        
+        # Pass-through Authorization header for CGI/FastCGI
+        RewriteCond %{HTTP:Authorization} ^(.+)
+        RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]
 
         <Location /rewrite>
             RewriteEngine on

Added: Catalyst-Runtime/5.80/branches/moose/t/live_engine_request_auth.t
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/t/live_engine_request_auth.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/branches/moose/t/live_engine_request_auth.t	2008-04-22 19:51:48 UTC (rev 7624)
@@ -0,0 +1,43 @@
+#!perl
+
+# This tests to make sure the Authorization header is passed through by the engine.
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 7;
+use Catalyst::Test 'TestApp';
+
+use Catalyst::Request;
+use HTTP::Headers;
+use HTTP::Request::Common;
+
+{
+    my $creq;
+
+    my $request = GET(
+        'http://localhost/dump/request',
+        'Authorization' => 'Basic dGVzdDoxMjM0NQ==',
+    );
+
+    ok( my $response = request($request), 'Request' );
+    ok( $response->is_success, 'Response Successful 2xx' );
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );
+    like( $response->content, qr/'Catalyst::Request'/,
+        'Content is a serialized Catalyst::Request' );
+
+    {
+        no strict 'refs';
+        ok(
+            eval '$creq = ' . $response->content,
+            'Unserialize Catalyst::Request'
+        );
+    }
+
+    isa_ok( $creq, 'Catalyst::Request' );
+    
+    is( $creq->header('Authorization'), 'Basic dGVzdDoxMjM0NQ==', 'auth header ok' );
+}


Property changes on: Catalyst-Runtime/5.80/branches/moose/t/live_engine_request_auth.t
___________________________________________________________________
Name: svn:keywords
   + Id

Added: Catalyst-Runtime/5.80/branches/moose/t/something/Makefile.PL
===================================================================

Added: Catalyst-Runtime/5.80/branches/moose/t/unit_utils_subdir.t
===================================================================
--- Catalyst-Runtime/5.80/branches/moose/t/unit_utils_subdir.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/branches/moose/t/unit_utils_subdir.t	2008-04-22 19:51:48 UTC (rev 7624)
@@ -0,0 +1,26 @@
+use Test::More tests=>7;
+
+use strict;
+use warnings;
+
+# simulates an entire testapp rooted at t/something
+# except without bothering creating it since its
+# only the -e check on the Makefile.PL that matters
+
+BEGIN { use_ok 'Catalyst::Utils' }
+use FindBin;
+
+$INC{'TestApp.pm'} = "$FindBin::Bin/something/script/foo/../../lib/TestApp.pm";
+my $home = Catalyst::Utils::home('TestApp');
+like($home, qr/t\/something/, "has path TestApp/t/something"); 
+unlike($home, qr/\/script\/foo/, "doesn't have path /script/foo");
+
+$INC{'TestApp.pm'} = "$FindBin::Bin/something/script/foo/bar/../../../lib/TestApp.pm";
+$home = Catalyst::Utils::home('TestApp');
+like($home, qr/t\/something/, "has path TestApp/t/something"); 
+unlike($home, qr/\/script\/foo\/bar/, "doesn't have path /script/foo");
+
+$INC{'TestApp.pm'} = "$FindBin::Bin/something/script/../lib/TestApp.pm";
+$home = Catalyst::Utils::home('TestApp');
+like($home, qr/t\/something/, "has path TestApp/t/something"); 
+unlike($home, qr/\/script\/foo/, "doesn't have path /script/foo");




More information about the Catalyst-commits mailing list