-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix HTTP::Message::PSGI handling a delayed writer with no content
If a delayed writer is used, but ->write is never called, the body arrayref would never get created, leading to errors.
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use HTTP::Message::PSGI; | ||
use HTTP::Request; | ||
use HTTP::Response; | ||
|
||
my $app = sub { | ||
my ($env) = @_; | ||
return sub { | ||
my ($responder) = @_; | ||
my $writer = $responder->([ 200, [] ]); | ||
$writer->close; | ||
}; | ||
}; | ||
|
||
my $env = req_to_psgi(HTTP::Request->new(POST => "http://localhost/post", [ ], 'hello')); | ||
|
||
my $response = HTTP::Response->from_psgi($app->($env)); | ||
|
||
is($response->content, '', 'delayed writer without write gives empty content'); | ||
|
||
done_testing; |