X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FQspawn.pm;h=52aea3eba472e0ff8bfe2b79e21893eb24c1ff56;hb=a71cb67a1237c450a9cbbd6738c5af3b73ba4c61;hp=3425e5e4558ba3911d0979ab01ea534c47434f86;hpb=fb0afdaa35d778c237c40b10216c38e360b248b3;p=public-inbox.git
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 3425e5e4..52aea3eb 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors
+# Copyright (C) 2016-2020 all contributors
# License: AGPL-3.0+
# Like most Perl modules in public-inbox, this is internal and
@@ -243,6 +243,7 @@ sub psgi_return_init_cb {
my ($self) = @_;
my $r = rd_hdr($self) or return;
my $env = $self->{psgi_env};
+ my $filter = delete $env->{'qspawn.filter'};
my $wcb = delete $env->{'qspawn.wcb'};
my $async = delete $self->{async};
if (scalar(@$r) == 3) { # error
@@ -257,6 +258,7 @@ sub psgi_return_init_cb {
} elsif ($async) {
# done reading headers, handoff to read body
my $fh = $wcb->($r); # scalar @$r == 2
+ $fh = $filter->attach($fh) if $filter;
$self->{fh} = $fh;
$async->async_pass($env->{'psgix.io'}, $fh,
delete($self->{hdr_buf}));
@@ -264,7 +266,7 @@ sub psgi_return_init_cb {
require PublicInbox::GetlineBody;
$r->[2] = PublicInbox::GetlineBody->new($self->{rpipe},
\&event_step, $self,
- ${$self->{hdr_buf}});
+ ${$self->{hdr_buf}}, $filter);
$wcb->($r);
}
@@ -294,6 +296,10 @@ sub psgi_return_start { # may run later, much later...
# psgi_return will return an anonymous
# sub for the PSGI server to call
#
+# $env->{'qspawn.filter'} - filter object, responds to ->attach for
+# pi-httpd.async and ->translate for generic
+# PSGI servers
+#
# $limiter - the Limiter object to use (uses the def_limiter if not given)
#
# $parse_hdr - Initial read function; often for parsing CGI header output.