## We need to figure out what kind of body we have...
my $body = $res->body;
if(defined $body) {
- if(blessed($body) && $body->can('read') or ref($body) eq 'GLOB') {
- # Body is a filehandle like thingy. We can jusrt send this along
- # to plack without changing it.
+ if(
+ (blessed($body) && $body->can('getline'))
+ or ref($body) eq 'GLOB'
+ ) {
+ # Body is an IO handle that meets the PSGI spec
+ } elsif(blessed($body) && $body->can('read')) {
+ # In the past, Catalyst only looked for read not getline. It is very possible
+ # that one might have an object that respected read but did not have getline.
+ # As a result, we need to handle this case for backcompat.
+
+ # We will just do the old loop for now but someone could write a proxy
+ # object to wrap getline and proxy read
+ my $got;
+ do {
+ $got = read $body, my ($buffer), $CHUNKSIZE;
+ $got = 0 unless $self->write($c, $buffer );
+ } while $got > 0;
+
+ close $body;
+ return;
} else {
# Looks like for backcompat reasons we need to be able to deal
# with stringyfiable objects.