X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=ff2e79785161a6f657c76698942a3019ef7491b2;hp=40d4281bc9c8761f0cae3d0e541f23ca5574edc1;hb=4ab87e274ac0a05f98c10a4cdba467ba4398b0d3;hpb=c6ef5e69c5192516590db9aa162c29f3424cc033 diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 40d4281..ff2e797 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -30,13 +30,8 @@ See L. =head1 METHODS -=over 4 -=item $self->finalize_output - -, see finalize_body - -=item $self->finalize_body($c) +=head2 $self->finalize_body($c) Finalize body. Prints the response output. @@ -47,7 +42,7 @@ sub finalize_body { if ( ref $c->response->body && $c->response->body->can('read') ) { while ( !$c->response->body->eof() ) { $c->response->body->read( my $buffer, $CHUNKSIZE ); - $self->write( $c, $buffer ); + last unless $self->write( $c, $buffer ); } $c->response->body->close(); } @@ -56,7 +51,9 @@ sub finalize_body { } } -=item $self->finalize_cookies($c) +=head2 $self->finalize_cookies($c) + +Create CGI::Cookies from $c->res->cookies, and set them as response headers. =cut @@ -78,19 +75,23 @@ sub finalize_cookies { push @cookies, $cookie->as_string; } - if (@cookies) { - $c->res->headers->push_header( 'Set-Cookie' => join ',', @cookies ); + for my $cookie (@cookies) { + $c->res->headers->push_header( 'Set-Cookie' => $cookie ); } } -=item $self->finalize_error($c) +=head2 $self->finalize_error($c) + +Output an apropriate error message, called if there's an error in $c +after the dispatch has finished. Will output debug messages if Catalyst +is in debug mode, or a `please come back later` message otherwise. =cut sub finalize_error { my ( $self, $c ) = @_; - $c->res->headers->content_type('text/html'); + $c->res->content_type('text/html; charset=utf-8'); my $name = $c->config->{name} || 'Catalyst Application'; my ( $title, $error, $infos ); @@ -98,11 +99,15 @@ sub finalize_error { # For pretty dumps local $Data::Dumper::Terse = 1; - $error = join '', - map { '' . encode_entities($_) . '' } - @{ $c->error }; + $error = join '', map { + '

' + . encode_entities($_) + . '

' + } @{ $c->error }; $error ||= 'No output'; + $error = qq{
$error
}; $title = $name = "$name on Catalyst $Catalyst::VERSION"; + $name = "

$name

"; # Don't show context in the dump delete $c->req->{_context}; @@ -120,20 +125,13 @@ sub finalize_error { my @infos; my $i = 0; - warn "BAAR"; for my $dump ( $c->dump_these ) { - warn "FOOO"; my $name = $dump->[0]; my $value = encode_entities( Dumper $dump->[1] ); push @infos, sprintf <<"EOF", $name, $value; -
- - %s - -
-
+

%s

-
%s
+
%s
EOF $i++; @@ -147,28 +145,31 @@ EOF
 (en) Please come back later
 (de) Bitte versuchen sie es spaeter nocheinmal
-(nl) Gelieve te komen later terug
+(at) Konnten's bitt'schoen spaeter nochmal reinschauen
 (no) Vennligst prov igjen senere
-(fr) Veuillez revenir plus tard
-(es) Vuelto por favor mas adelante
-(pt) Voltado por favor mais tarde
-(it) Ritornato prego più successivamente
+(dk) Venligst prov igen senere
+(pl) Prosze sprobowac pozniej
 
$name = ''; } $c->res->body( <<"" ); - + + + + $title -