X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=60a6e9edd019a165eab2a3c7600ff1481bfe5863;hp=860822e73d62ddef1512cb8d40ec20b00cc484e9;hb=17f90595f57c5153402809ea12ecdd00b3c44a0f;hpb=88e5a8b0c4d28e46b8ba6b6b9567063e57af9063 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 860822e..60a6e9e 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -205,7 +205,7 @@ sub composed_stats_class { __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90117'; +our $VERSION = '5.90124'; $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases sub import { @@ -1601,11 +1601,11 @@ sub uri_for { $path .= '/'; } - my $fragment = ((scalar(@args) && ref($args[-1]) eq 'SCALAR') ? pop @args : undef ); + my $fragment = ((scalar(@args) && ref($args[-1]) eq 'SCALAR') ? ${pop @args} : undef ); unless(blessed $path) { if (defined($path) and $path =~ s/#(.+)$//) { - if(defined($1) and $fragment) { + if(defined($1) and defined $fragment) { carp "Abiguious fragment declaration: You cannot define a fragment in '$path' and as an argument '$fragment'"; } if(defined($1)) { @@ -1640,8 +1640,9 @@ sub uri_for { if($num_captures) { unless($expanded_action->match_captures_constraints($c, $captures)) { - carp "captures [@{$captures}] do not match the type constraints in actionchain ending with '$expanded_action'"; - return; + $c->log->debug("captures [@{$captures}] do not match the type constraints in actionchain ending with '$expanded_action'") + if $c->debug; + return undef; } } @@ -1656,8 +1657,9 @@ sub uri_for { # At this point @encoded_args is the remaining Args (all captures removed). if($expanded_action->has_args_constraints) { unless($expanded_action->match_args($c,\@args)) { - carp "args [@args] do not match the type constraints in action '$expanded_action'"; - return; + $c->log->debug("args [@args] do not match the type constraints in action '$expanded_action'") + if $c->debug; + return undef; } } } @@ -1725,7 +1727,7 @@ sub uri_for { if(defined $fragment) { if(blessed $path) { - $fragment = encode_utf8(${$fragment}); + $fragment = encode_utf8($fragment); $fragment =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go; $fragment =~ s/ /+/g; } @@ -2194,16 +2196,27 @@ sub finalize { $c->log_response; - if ($c->use_stats) { - my $elapsed = $c->stats->elapsed; - my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; - $c->log->info( - "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); - } + $c->log_stats if $c->use_stats; return $c->response->status; } +=head2 $c->log_stats + +Logs statistics. + +=cut + +sub log_stats { + my $c = shift; + + my $elapsed = $c->stats->elapsed; + my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; + $c->log->info( + "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); +} + + =head2 $c->finalize_body Finalizes body. @@ -3465,7 +3478,7 @@ sub apply_default_middlewares { condition => sub { my ($env) = @_; return if $app->config->{ignore_frontend_proxy}; - return $env->{REMOTE_ADDR} eq '127.0.0.1'; + return $env->{REMOTE_ADDR} && $env->{REMOTE_ADDR} eq '127.0.0.1'; }, ); } @@ -5009,6 +5022,8 @@ revmischa: Mischa Spiegelmock Robert Sedlacek +rrwo: Robert Rothenberg + SpiceMan: Marcel Montes sky: Arthur Bergman