From: Tomas Doran Date: Thu, 27 Oct 2011 07:09:28 +0000 (-0700) Subject: Move read_chunk to the request X-Git-Tag: 5.90008~16^2~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=87f504360777193d96945014faa1d058224fcb0e Move read_chunk to the request --- diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index e3fe476..9a6c287 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -739,7 +739,7 @@ sub read { } } -=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 @@ -749,7 +749,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 diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index aa2c03d..b712e47 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -50,10 +50,15 @@ has headers => ( has _context => ( is => 'rw', weak_ref => 1, - handles => ['read'], + handles => ['read'], # XXX FIXME! clearer => '_clear_context', ); +sub read_chunk { + my $self = shift; + return $self->env->{'psgi.input'}->read(@_); +} + has body_parameters => ( is => 'rw', required => 1, @@ -491,6 +496,10 @@ Reads a chunk of data from the request body. This method is intended to be used in a while loop, reading $maxlength bytes on every call. $maxlength defaults to the size of the request if not specified. +=head2 $req->read_chunk(\$buff, $max) + +Reads a chunk.. + You have to set MyApp->config(parse_on_demand => 1) to use this directly. =head2 $req->referer