Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Dec 3, 2013
1 parent d3fc874 commit 7dafe51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions lib/HTTP/Message/PSGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,12 @@ sub res_from_psgi {
my $res;
if (ref $psgi_res eq 'ARRAY') {
_res_from_psgi($psgi_res, \$res);
}
elsif (ref $psgi_res eq 'CODE') {
} elsif (ref $psgi_res eq 'CODE') {
$psgi_res->(sub {
_res_from_psgi($_[0], \$res);
});
}
else {
my $response = defined $psgi_res ? "'$psgi_res'" : 'undef';
die "Bad response $response";
} else {
Carp::croak("Bad response: ", defined $psgi_res ? $psgi_res : 'undef');
}

return $res;
Expand Down
4 changes: 2 additions & 2 deletions t/HTTP-Message-PSGI/unknown_response.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ my $app = sub { $res };
my $env = req_to_psgi(HTTP::Request->new(GET => "http://localhost/"));

eval { HTTP::Response->from_psgi($app->($env)) };
like($@, qr/Bad response undef/, 'converting undef PSGI response results in error');
like($@, qr/Bad response: undef/, 'converting undef PSGI response results in error');

$res = 5;

eval { HTTP::Response->from_psgi($app->($env)) };
like($@, qr/Bad response '5'/, 'converting invalid PSGI response results in error');
like($@, qr/Bad response: 5/, 'converting invalid PSGI response results in error');

done_testing;

0 comments on commit 7dafe51

Please sign in to comment.