about summary refs log tree commit homepage
path: root/lib/PublicInbox/Qspawn.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-03-21 02:03:44 +0000
committerEric Wong <e@yhbt.net>2020-03-25 01:48:34 +0000
commita71cb67a1237c450a9cbbd6738c5af3b73ba4c61 (patch)
tree514fd2f9f289622615069850828475c09fc8ecc4 /lib/PublicInbox/Qspawn.pm
parentdecbb9936a25dfedf6ecd916d8e0403f06217ec9 (diff)
downloadpublic-inbox-a71cb67a1237c450a9cbbd6738c5af3b73ba4c61.tar.gz
We'll be supporting gzipped from sqlite3(1) dumps
for altid files in future commits.

In the future (and if we survive), we may replace
Plack::Middleware::Deflater with our own GzipFilter to work
better with asynchronous responses without relying on
memory-intensive anonymous subs.
Diffstat (limited to 'lib/PublicInbox/Qspawn.pm')
-rw-r--r--lib/PublicInbox/Qspawn.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 63ec3648..52aea3eb 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -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.