X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=876c82276ba21faafa3d61511e3b19eb0cc7cac2;hb=4716267fb6eef69c420a193cc6a298d9926844f1;hp=ba926cb0ba48969a2bb5cbc8b1bdd652b6cf0f9a;hpb=b96d41e6a80ff8d00e4030e55c0fc1ae8c11aa76;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ba926cb..876c822 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -127,7 +127,9 @@ sub finalize { if ( my $location = $c->res->redirect ) { $c->log->debug(qq/Redirecting to "$location"/) if $c->debug; $c->res->headers->header( Location => $location ); + $c->res->headers->remove_content_headers; $c->res->status(302); + return $c->finalize_headers; } if ( !$c->res->output || $#{ $c->error } >= 0 ) { @@ -373,11 +375,13 @@ sub handler ($$) { for my $begin ( @{ $c->get_action( 'begin', $namespace ) } ) { $c->state( $c->execute( @{ $begin->[0] } ) ); } - for my $result ( @{ $c->get_action( $action, $default ) }[-1] ) { + for my $result ( @{ $c->get_action( $action, $default ) }[-1] ) + { $c->state( $c->execute( @{ $result->[0] } ) ); last unless $default; } - for my $end ( reverse @{ $c->get_action( 'end', $namespace ) } ) { + for my $end ( reverse @{ $c->get_action( 'end', $namespace ) } ) + { $c->state( $c->execute( @{ $end->[0] } ) ); } } @@ -638,10 +642,10 @@ sub set_action { my %flags; for my $attr ( @{$attrs} ) { - if ( $attr =~ /^(Local|Relative)$/ ) { $flags{local}++ } - elsif ( $attr =~ /^(Global|Absolute)$/ ) { $flags{global}++ } - elsif ( $attr =~ /^Path\((.+)\)$/i ) { $flags{path} = $1 } - elsif ( $attr =~ /^Private$/i ) { $flags{private}++ } + if ( $attr =~ /^(Local|Relative)$/ ) { $flags{local}++ } + elsif ( $attr =~ /^(Global|Absolute)$/ ) { $flags{global}++ } + elsif ( $attr =~ /^Path\((.+)\)$/i ) { $flags{path} = $1 } + elsif ( $attr =~ /^Private$/i ) { $flags{private}++ } elsif ( $attr =~ /^(Regex|Regexp)\((.+)\)$/i ) { $flags{regex} = $2 } } @@ -733,10 +737,24 @@ sub setup_actions { my ( $code, $attrs ) = @{$action}; my $name = ''; no strict 'refs'; - for my $sym ( values %{ $comp . '::' } ) { - if ( *{$sym}{CODE} && *{$sym}{CODE} == $code ) { - $name = *{$sym}{NAME}; - $self->set_action( $name, $code, $comp, $attrs ); + my @cache = ( $comp, @{"$comp\::ISA"} ); + my @namespaces; + my %seen; + while ( my $namespace = shift @cache ) { + push @namespaces, $namespace; + for my $isa ( @{"$comp\::ISA"} ) { + next if $seen{$isa}; + push @cache, $isa; + $seen{$isa}++; + } + } + for my $namespace (@namespaces) { + for my $sym ( values %{ $namespace . '::' } ) { + if ( *{$sym}{CODE} && *{$sym}{CODE} == $code ) { + $name = *{$sym}{NAME}; + $self->set_action( $name, $code, $comp, $attrs ); + last; + } } } } @@ -810,9 +828,9 @@ sub _prefix { sub _class2prefix { my $class = shift || ''; my $prefix; - if ($class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/) { - $prefix = lc $2; - $prefix =~ s/\:\:/\//g; + if ( $class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/ ) { + $prefix = lc $2; + $prefix =~ s/\:\:/\//g; } return $prefix; }