Avoid dying when $c->ref->body is a ref but not an object
Yuval Kogman [Sat, 24 Jun 2006 11:59:15 +0000 (11:59 +0000)]
lib/Catalyst/Engine.pm

index ce90738..3a73c04 100644 (file)
@@ -41,7 +41,8 @@ Finalize body.  Prints the response output.
 sub finalize_body {
     my ( $self, $c ) = @_;
     my $body = $c->response->body;
-    if ( ref $body && ( $body->can('read') || ref($body) eq 'GLOB' ) ) {
+    no warnings 'uninitialized';
+    if ( Scalar::Util::blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) {
         while ( !eof $body ) {
             read $body, my ($buffer), $CHUNKSIZE;
             last unless $self->write( $c, $buffer );