X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=22309080dd0066a22271ec02307a59dc491256a4;hb=4d98d16dff4df87a96054967d73cf3c7a4801344;hp=f378d57d6f4de367b7ac872bcaa21c7c0f20f61b;hpb=fbcc39ad23f2bbecf5d84c9ba581e6af86fcd460;p=catagits%2FCatalyst-Runtime.git
diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm
index f378d57..2230908 100644
--- a/lib/Catalyst/Engine.pm
+++ b/lib/Catalyst/Engine.pm
@@ -7,13 +7,17 @@ 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;
+# Amount of data to read from input on each pass
+our $CHUNKSIZE = 4096;
+
=head1 NAME
Catalyst::Engine - The Catalyst Engine
@@ -40,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)
@@ -105,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+