]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Qspawn.pm
wwwstream: reduce object graph depth
[public-inbox.git] / lib / PublicInbox / Qspawn.pm
index c09e8d2c227b0b6bc01ddc1a13598d72c73d6c72..88b6d390a0721e529f31f9826144dad641aa067c 100644 (file)
@@ -25,8 +25,8 @@
 
 package PublicInbox::Qspawn;
 use strict;
-use warnings;
 use PublicInbox::Spawn qw(popen_rd);
+use PublicInbox::GzipFilter;
 
 # n.b.: we get EAGAIN with public-inbox-httpd, and EINTR on other PSGI servers
 use Errno qw(EAGAIN EINTR);
@@ -48,7 +48,7 @@ sub _do_spawn {
        my ($cmd, $cmd_env, $opt) = @{delete $self->{args}};
        my %o = %{$opt || {}};
        $self->{limiter} = $limiter;
-       foreach my $k (PublicInbox::Spawn::RLIMITS()) {
+       foreach my $k (@PublicInbox::Spawn::RLIMITS) {
                if (defined(my $rlimit = $limiter->{$k})) {
                        $o{$k} = $rlimit;
                }
@@ -255,7 +255,9 @@ 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 $filter = delete $env->{'qspawn.filter'} //
+               PublicInbox::GzipFilter::qsp_maybe($r->[1], $env);
+
        my $wcb = delete $env->{'qspawn.wcb'};
        my $async = delete $self->{async};
        if (scalar(@$r) == 3) { # error
@@ -358,7 +360,7 @@ sub new {
 
 sub setup_rlimit {
        my ($self, $name, $config) = @_;
-       foreach my $rlim (PublicInbox::Spawn::RLIMITS()) {
+       foreach my $rlim (@PublicInbox::Spawn::RLIMITS) {
                my $k = lc($rlim);
                $k =~ tr/_//d;
                $k = "publicinboxlimiter.$name.$k";