From 5186d1f71d83ad84104c93da6bd27908a1610403 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 5 Mar 2016 05:41:12 +0000 Subject: t/httpd-corner: additional callback test Just to ensure we hit the code path independently of WWW code. --- t/httpd-corner.psgi | 9 +++++++++ t/httpd-corner.t | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 't') diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi index 349b35df..da8a2ee8 100644 --- a/t/httpd-corner.psgi +++ b/t/httpd-corner.psgi @@ -47,6 +47,15 @@ my $app = sub { } elsif ($path eq '/host-port') { $code = 200; push @$body, "$env->{REMOTE_ADDR}:$env->{REMOTE_PORT}"; + } elsif ($path eq '/callback') { + return sub { + my ($res) = @_; + my $buf = "hello world\n"; + push @$h, 'Content-Length', length($buf); + my $fh = $res->([200, $h]); + $fh->write($buf); + $fh->close; + } } [ $code, $h, $body ] diff --git a/t/httpd-corner.t b/t/httpd-corner.t index 19564074..a6238e48 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -76,6 +76,15 @@ my $spawn_httpd = sub { $spawn_httpd->('-W0'); } +{ + my $conn = conn_for($sock, 'streaming callback'); + $conn->write("GET /callback HTTP/1.0\r\n\r\n"); + ok($conn->read(my $buf, 8192), 'read response'); + my ($head, $body) = split(/\r\n\r\n/, $buf); + is($body, "hello world\n", 'callback body matches expected'); +} + + # Unix domain sockets { my $u = IO::Socket::UNIX->new(Type => SOCK_STREAM, Peer => $upath); -- cgit v1.2.3-24-ge0c7