about summary refs log tree commit homepage
path: root/script/mwrap-rproxy
diff options
context:
space:
mode:
Diffstat (limited to 'script/mwrap-rproxy')
-rw-r--r--script/mwrap-rproxy12
1 files changed, 9 insertions, 3 deletions
diff --git a/script/mwrap-rproxy b/script/mwrap-rproxy
index be6dcbe..a5572c5 100644
--- a/script/mwrap-rproxy
+++ b/script/mwrap-rproxy
@@ -8,10 +8,12 @@ use Plack::Runner;
 use Getopt::Long qw(:config no_ignore_case no_auto_abbrev pass_through);
 my $usage = "$0 --socket-dir=/path/to/socket-dir [PLACKUP_OPTIONS]\n";
 my $socket_dir;
-GetOptions('socket-dir=s' => \$socket_dir) or die $usage;
+my $gz = 1;
+GetOptions('socket-dir=s' => \$socket_dir, 'deflate!' => \$gz) or die $usage;
 $socket_dir //= ($ENV{MWRAP} // '') =~ m!\bsocket_dir:([^,]+)! ? $1 : undef;
 $socket_dir // die $usage;
-my $app = Devel::Mwrap::Rproxy->new($socket_dir);
+my $rproxy = Devel::Mwrap::Rproxy->new($socket_dir);
+my $app = sub { $rproxy->call(@_) };
 my $runner = Plack::Runner->new;
 $runner->parse_options(@ARGV);
 if (($ENV{LISTEN_PID} // 0) == $$) {
@@ -26,4 +28,8 @@ Inherited socket (fd=3) is non-blocking, making it blocking.
                 $runner->set_options(listen_sock => $s);
         }
 }
-$runner->run(sub { $app->call(@_) });
+if ($gz) {
+        require Plack::Middleware::Deflater;
+        $app = Plack::Middleware::Deflater->wrap($app);
+}
+$runner->run($app);