Skip to content

Commit

Permalink
Determine the object has getline method in response body as file hand…
Browse files Browse the repository at this point in the history
…le(e.g. File::Temp)。
  • Loading branch information
tokuhirom committed Oct 19, 2010
1 parent fd3d26e commit cc1d186
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Plack/Response.pm
Expand Up @@ -103,7 +103,7 @@ sub _body {
my $self = shift;
my $body = $self->body;
$body = [] unless defined $body;
if (!ref $body or Scalar::Util::blessed($body) && overload::Method($body, q(""))) {
if (!ref $body or Scalar::Util::blessed($body) && overload::Method($body, q("")) && !$body->can('getline')) {
return [ $body ];
} else {
return $body;
Expand Down
6 changes: 6 additions & 0 deletions t/Plack-Response/body.t
Expand Up @@ -4,6 +4,7 @@ use FindBin;
use Test::More;
use Plack::Response;
use URI;
use File::Temp;

sub r($) {
my $res = Plack::Response->new(200);
Expand All @@ -30,5 +31,10 @@ is_deeply r [ "Hello", "World" ], [ "Hello", "World" ];
is_deeply r $uri, [ $uri ];
}

{
my $tmp = File::Temp->new("baz"); # File::Temp has stringify method, but it is-a IO::Handle.
is_deeply r $tmp, $tmp;
}

done_testing;

0 comments on commit cc1d186

Please sign in to comment.