]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/httpd-corner: additional callback test
authorEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:41:12 +0000 (05:41 +0000)
committerEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:41:12 +0000 (05:41 +0000)
Just to ensure we hit the code path independently of
WWW code.

t/httpd-corner.psgi
t/httpd-corner.t

index 349b35dfb22d32df1096af54cba0f4001b19f7b0..da8a2ee8b646ef7b9937c9d72ab9616e924f4fd3 100644 (file)
@@ -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 ]
index 19564074eaa00ec4d2060777a7d68cc16c1823a6..a6238e4871f09ed4658d4c317de9b05c3f5faf88 100644 (file)
@@ -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);