returning true.
Having a response body is indicated by $c->res->body being defined.
+ - Fix bug with calling $upload->slurp multiple times in one request
+ not working as expected as the file handle wasn't returned to
+ the zero position. (Adam Sjøgren)
+
5.80031 2011-01-31 08:13:02
Bug fixes:
use Catalyst::Exception;
use File::Copy ();
-use IO::File ();
+use IO::File qw( SEEK_SET );
use File::Spec::Unix;
has filename => (is => 'rw');
Returns a scalar containing the contents of the temporary file.
+Note that this method will cause the filehandle pointed to by
+C<< $upload->fh >> to be seeked to the start of the file,
+and the file handle to be put into binary mode.
+
=cut
sub slurp {
binmode( $handle, $layer );
+ $handle->seek(0, SEEK_SET);
while ( $handle->sysread( my $buffer, 8192 ) ) {
$content .= $buffer;
}
+ $handle->seek(0, SEEK_SET);
return $content;
}
sub slurp : Relative {
my ( $self, $c ) = @_;
$c->response->content_type('text/plain; charset=utf-8');
+ my $upload = $c->request->upload('slurp');
+ my $contents = $upload->slurp;
+ my $contents2 = $upload->slurp;
+ die("Slurp not callable multiple times") unless $contents eq $contents2;
$c->response->output( $c->request->upload('slurp')->slurp );
}