File: empty_streamed_response.t

package info (click to toggle)
libplack-perl 1.0051-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,484 kB
  • sloc: perl: 5,289; sh: 4; makefile: 4; javascript: 1
file content (23 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use Test::More;
use HTTP::Message::PSGI;
use Plack::Middleware::AccessLog::Timed;
use HTTP::Request;
use HTTP::Response;

# Plack::Middleware::AccessLog::Timed is used here as it always uses
# a coderef in response_cb to wrap the response body.
my $app = Plack::Middleware::AccessLog::Timed->wrap(
    sub { return [ 200, [], []] },
    logger => sub {},
);

my $env = req_to_psgi(HTTP::Request->new(POST => "http://localhost/post", [ ], 'hello'));

my $response = HTTP::Response->from_psgi($app->($env));

is($response->content, '', 'undef response body converted to empty string');

done_testing;