Skip Menu |

This queue is for tickets about the Catalyst CPAN distribution.

Report information
The Basics
Id: 17682
Status: resolved
Priority: 0/
Queue: Catalyst

People
Owner: Nobody in particular
Requestors: geoff [...] laxan.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.63
Fixed in: (no value)



Subject: $c->response->body() only accepts fake file handles
I'm looking at Catalyst version 5.64, but that's not in the RT list yet. The value passed to $c->response->body() can be either a string to output, or a file handle to read output from. However it only accepts things like IO::File objects, which are 'pretend' file handles. Real file handles created with the built-in 'open' function just get treated as strings, outputting 'GLOB(blah)'. Attached is a patch to fix this. By using indirect object notation to call the methods the same code will work for both types of file handle. I've tested this a bit and it seems to work fine, but I haven't got time to put together proper tests for it. While I was at it I put a new variable in that bit of code to avoid all those repeated method calls and make the code slightly tidier.
Subject: glob_compatability.diff
--- lib/Catalyst/Engine.pm.orig 2006-02-16 19:29:04.000000000 +0000 +++ lib/Catalyst/Engine.pm 2006-02-16 19:30:25.000000000 +0000 @@ -42,15 +42,16 @@ sub finalize_body { my ( $self, $c ) = @_; - if ( ref $c->response->body && $c->response->body->can('read') ) { - while ( !$c->response->body->eof() ) { - $c->response->body->read( my $buffer, $CHUNKSIZE ); + my $body = $c->response->body; + if ( ref $body && ($body->can('read') || ref($body) eq 'GLOB') ) { + while ( !eof $body ) { + read $body, my $buffer, $CHUNKSIZE; last unless $self->write( $c, $buffer ); } - $c->response->body->close(); + close $body; } else { - $self->write( $c, $c->response->body ); + $self->write( $c, $body ); } }