X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine.pm;h=7111eec04c866de2ccdd041c8c90fbc6dc87c366;hb=f083854e255c33d3e82befa09152284127d426c1;hp=567c337901e48b55b4c77454afd54aa54c42fd8c;hpb=be5c8c2413b7b83b99cdae51d094907b0343583d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 567c337..7111eec 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -345,12 +345,6 @@ sub finalize_headers { return; } -=head2 $self->finalize_read($c) - -=cut - -sub finalize_read { } - =head2 $self->finalize_uploads($c) Clean up after uploads, deleting temp files. @@ -399,7 +393,6 @@ sub prepare_body { # paranoia against wrong Content-Length header my $remaining = $length - $c->request->_read_position; if ( $remaining > 0 ) { - $self->finalize_read($c); Catalyst::Exception->throw( "Wrong Content-Length value: $length" ); } @@ -720,35 +713,10 @@ Maintains the read_length and read_position counters as data is read. sub read { my ( $self, $c, $maxlength ) = @_; - my $request = $c->request; - my $remaining = $request->_read_length - $request->_read_position; - $maxlength ||= $CHUNKSIZE; - - # Are we done reading? - if ( $remaining <= 0 ) { - $self->finalize_read($c); - return; - } - - my $readlen = ( $remaining > $maxlength ) ? $maxlength : $remaining; - my $rc = $self->read_chunk( $c, my $buffer, $readlen ); - if ( defined $rc ) { - if (0 == $rc) { # Nothing more to read even though Content-Length - # said there should be. - $self->finalize_read; - return; - } - my $request = $c->request; - $request->_read_position( $request->_read_position + $rc ); - return $buffer; - } - else { - Catalyst::Exception->throw( - message => "Unknown error reading input: $!" ); - } + $c->request->read($maxlength); } -=head2 $self->read_chunk($c, $buffer, $length) +=head2 $self->read_chunk($c, \$buffer, $length) Each engine implements read_chunk as its preferred way of reading a chunk of data. Returns the number of bytes read. A return of 0 indicates that @@ -758,7 +726,7 @@ there is no more data to be read. sub read_chunk { my ($self, $ctx) = (shift, shift); - return $ctx->request->env->{'psgi.input'}->read(@_); + return $ctx->request->read_chunk(@_); } =head2 $self->read_length