[Catalyst] Re: Redirects // Re: forwarding to chained actions
Bill Moseley
moseley at hank.org
Fri Apr 27 21:42:06 GMT 2007
On Fri, Apr 27, 2007 at 10:30:01PM +0200, A. Pagaltzis wrote:
> Various nitpickery corrected:
>
> sub post_redirect {
> my ( $c, $loc ) = @_;
>
> my $is_rel_uri = $loc !~ m{ :// }x;
>
> my $is_old_proto = do {
> my $p = $c->request->protocol;
> my ( $maj, $min ) = ( $p =~ m{ \A HTTP / 0* ( \d+ ) \. ( \d+ ) \z }x );
> not $maj or $maj == 1 and $min == 0;
> };
>
> $c->res->redirect(
> ( $is_rel_uri ? $c->uri_for( $loc ) : $loc ),
> ( $is_old_proto ? 302 : 303 ),
> );
> }
I was going to say "Quick! Make a plugin on CPAN" but then realized
the above exceeds the line limit for Catalyst plugins. ;)
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list