Don't set a content-length from a filehandle object unless it reports a positive...
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 40791cd..809d2a4 100644 (file)
@@ -1427,7 +1427,8 @@ sub finalize_headers {
         # get the length from a filehandle
         if ( blessed( $c->response->body ) && $c->response->body->can('read') )
         {
-            if ( my $stat = stat $c->response->body ) {
+            my $stat = stat $c->response->body;
+            if ( $stat && $stat->size > 0 ) {
                 $c->response->content_length( $stat->size );
             }
             else {