unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] t/httpd-corner: additional callback test
Date: Sat,  5 Mar 2016 06:07:37 +0000	[thread overview]
Message-ID: <20160305060740.13472-2-e@80x24.org> (raw)
In-Reply-To: <20160305060740.13472-1-e@80x24.org>

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(+)

diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi
index 349b35d..da8a2ee 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 1956407..a6238e4 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);
-- 
EW


  reply	other threads:[~2016-03-05  6:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05  6:07 [PATCH 0/4] daemon-related cleanups Eric Wong
2016-03-05  6:07 ` Eric Wong [this message]
2016-03-05  6:07 ` [PATCH 2/4] daemon: drop listener sockets ASAP on termination Eric Wong
2016-03-05  6:07 ` [PATCH 3/4] daemon: avoid cyclic references for once-used callbacks Eric Wong
2016-03-05  6:07 ` [PATCH 4/4] daemon: simplify parent death handling Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160305060740.13472-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).