[Catalyst-commits] r7714 - in Catalyst-Runtime/5.70/trunk: . lib
lib/Catalyst lib/Catalyst/DispatchType t t/lib/TestApp/Controller
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Wed May 7 18:42:23 BST 2008
Author: bricas
Date: 2008-05-07 18:42:22 +0100 (Wed, 07 May 2008)
New Revision: 7714
Modified:
Catalyst-Runtime/5.70/trunk/Changes
Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm
Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm
Catalyst-Runtime/5.70/trunk/lib/Catalyst/Dispatcher.pm
Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm
Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_path.t
Log:
Fix for Path('0') handling (RT #29334)
Modified: Catalyst-Runtime/5.70/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.70/trunk/Changes 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/Changes 2008-05-07 17:42:22 UTC (rev 7714)
@@ -8,6 +8,7 @@
client disconnected before sending any headers. (Ton Voon)
- POD fix, IO::FileHandle => IO::Handle (RT #35690)
- Fix grammar on welcome page (RT #33236)
+ - Fix for Path('0') handling (RT #29334)
5.7012 2007-12-16 23:44:00
- Fix uri_for()'s and uri_with()'s handling of multibyte chars
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/Controller.pm 2008-05-07 17:42:22 UTC (rev 7714)
@@ -73,7 +73,7 @@
my ( $self, $c ) = @_;
if ( ref $c->action
&& $c->action->can('execute')
- && $c->req->action )
+ && defined $c->req->action )
{
$c->action->dispatch( $c );
}
@@ -248,7 +248,7 @@
sub _parse_Path_attr {
my ( $self, $c, $name, $value ) = @_;
- $value ||= '';
+ $value = '' if !defined $value;
if ( $value =~ m!^/! ) {
return ( 'Path', $value );
}
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm 2008-05-07 17:42:22 UTC (rev 7714)
@@ -47,7 +47,7 @@
sub match {
my ( $self, $c, $path ) = @_;
- $path ||= '/';
+ $path = '/' if !defined $path;
foreach my $action ( @{ $self->{paths}->{$path} || [] } ) {
next unless $action->match($c);
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst/Dispatcher.pm 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst/Dispatcher.pm 2008-05-07 17:42:22 UTC (rev 7714)
@@ -285,7 +285,7 @@
s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg for grep { defined } @{$c->req->captures||[]};
$c->log->debug( 'Path is "' . $c->req->match . '"' )
- if ( $c->debug && $c->req->match );
+ if ( $c->debug && length $c->req->match );
$c->log->debug( 'Arguments are "' . join( '/', @args ) . '"' )
if ( $c->debug && @args );
@@ -301,7 +301,7 @@
my ( $self, $name, $namespace ) = @_;
return unless $name;
- $namespace = join( "/", grep { length } split '/', $namespace || "" );
+ $namespace = join( "/", grep { length } split '/', ( defined $namespace ? $namespace : "" ) );
return $self->action_hash->{"$namespace/$name"};
}
Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm 2008-05-07 17:42:22 UTC (rev 7714)
@@ -1600,7 +1600,8 @@
}
my $method = $c->req->method || '';
- my $path = $c->req->path || '/';
+ my $path = $c->req->path;
+ $path = '/' unless length $path;
my $address = $c->req->address || '';
$c->log->debug(qq/"$method" request for "$path" from "$address"/)
Modified: Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/t/lib/TestApp/Controller/Root.pm 2008-05-07 17:42:22 UTC (rev 7714)
@@ -6,4 +6,11 @@
sub chain_root_index : Chained('/') PathPart('') Args(0) { }
+sub zero : Path('0') {
+ my ( $self, $c ) = @_;
+ $c->res->header( 'X-Test-Class' => ref($self) );
+ $c->response->content_type('text/plain; charset=utf-8');
+ $c->forward('TestApp::View::Dump::Request');
+}
+
1;
Modified: Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_path.t
===================================================================
--- Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_path.t 2008-05-07 17:15:02 UTC (rev 7713)
+++ Catalyst-Runtime/5.70/trunk/t/live_component_controller_action_path.t 2008-05-07 17:42:22 UTC (rev 7714)
@@ -10,7 +10,7 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 30*$iters;
+use Test::More tests => 36*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
@@ -124,4 +124,22 @@
'Content is a serialized Catalyst::Request'
);
}
+
+ {
+ ok( my $response = request('http://localhost/0'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ '0', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Root',
+ 'Test Class'
+ );
+ like(
+ $response->content,
+ qr/^bless\( .* 'Catalyst::Request' \)$/s,
+ 'Content is a serialized Catalyst::Request'
+ );
+ }
}
More information about the Catalyst-commits
mailing list