X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=544116d89f327d83365dc5e90be2080a80e94672;hb=e4d883627ffd461f5ad4c55f3d6f5126c6513616;hp=4170a084bd2f696cc132c7aee1eefddaff258383;hpb=4bd82c41837b80f57b4ca6a611a20d11d4830980;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 4170a08..544116d 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -7,9 +7,10 @@ use Data::Dumper; use HTML::Entities; use HTTP::Body; use HTTP::Headers; +use URI::QueryParam; # input position and length -__PACKAGE__->mk_accessors( qw/read_position read_length/ ); +__PACKAGE__->mk_accessors(qw/read_position read_length/); # Stringify to class use overload '""' => sub { return ref shift }, fallback => 1; @@ -43,8 +44,16 @@ Finalize body. Prints the response output. sub finalize_body { my ( $self, $c ) = @_; - - $self->write( $c, $c->response->output ); + 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 ); + } + $c->response->body->close(); + } + else { + $self->write( $c, $c->response->body ); + } } =item $self->finalize_cookies($c) @@ -81,7 +90,7 @@ sub finalize_cookies { 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 ); @@ -108,15 +117,26 @@ sub finalize_error { my $req = encode_entities Dumper $c->req; my $res = encode_entities Dumper $c->res; my $stash = encode_entities Dumper $c->stash; - $infos = <<""; -
-Request
-
$req
-Response
-
$res
-Stash
-
$stash
+ my @infos; + my $i = 0; + for my $dump ( $c->dump_these ) { + my $name = $dump->[0]; + my $value = encode_entities( Dumper $dump->[1] ); + push @infos, sprintf <<"EOF", $name, $value; +
+ + %s + +
+
+
+
%s
+
+EOF + $i++; + } + $infos = join "\n", @infos; } else { $title = $name; @@ -136,9 +156,26 @@ sub finalize_error { $name = ''; } $c->res->body( <<"" ); - + + + + $title +