From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8E55A1FAFC for ; Thu, 15 Dec 2022 20:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1671137578; bh=19STli29VaYHh9gylZwPpSyxWZO1I4QqW31aNDGZgzY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WsxYUQl1FtFXiylcPbNtyYSRvXMM4bjWwYg+pbtNiGOHkM2C8BiwuCsLLFXDoSEFU 6ScKXVYsUvx0TmCELZASnEt3al3eCF1Au3QQBqsqYEFy/fg1f/PDkcqA3h8nm+qoF+ fphEqwKPX2Q+QODLpsgf2iiV108BpeQ4qtWIGZGo= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 13/19] rproxy: enable deflater by default Date: Thu, 15 Dec 2022 20:52:49 +0000 Message-Id: <20221215205255.27840-14-e@80x24.org> In-Reply-To: <20221215205255.27840-1-e@80x24.org> References: <20221215205255.27840-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Ideally I want this in the main mwrap_httpd itself, but linking zlib may conflict with whatever an application uses. This will be useful for exposing the demo endpoint for public use. --- script/mwrap-rproxy | 12 +++++++++--- 1 file 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);