* Bill Moseley <[EMAIL PROTECTED]> [2007-04-27 20:55]: > sub post_redirect { > my ( $c, $location ) = @_; > my ($version) = $c->request->protocol =~ m/(\d+\.\d+)/; > > # Make location absolute > $location = $c->uri_for( $location ) > unless $location =~ /http/; > > $c->res->redirect( $location, ( $version && $version > 1.0 ? 303 : 302 )); > }
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 ), ); } Main change is because HTTP versions are not floats. (Someone tell me, when doesn’t comparing version strings properly suck?) -- *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1} &Just->another->Perl->hack; #Aristotle _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/