diff options
author | Eric Wong <e@yhbt.net> | 2020-04-21 06:57:34 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-04-22 07:04:45 +0000 |
commit | a318e758129d616b3b801db82c4735c680a2fbe8 (patch) | |
tree | ba9af6a937ecf8f2a7dc339a25f1ad2a0c0ddc75 /lib/PublicInbox | |
parent | a45aef4d6415553dd1f6744770b00ea9033f58d7 (diff) | |
download | public-inbox-a318e758129d616b3b801db82c4735c680a2fbe8.tar.gz |
This allows us to simplify some of our existing code and make future changes easier. I doubt anybody goes through the trouble to have a Perl installation without zlib support. The zlib source code is even bundled with Perl since 5.9.3 for systems without existing zlib development headers and libraries. Of course, zlib is also a requirement of git, too; and we're not going to stop using git :) [squashed: "wwwaltid: use gzipfilter up front"]
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/Mbox.pm | 17 | ||||
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 11 | ||||
-rw-r--r-- | lib/PublicInbox/WwwAltId.pm | 8 | ||||
-rw-r--r-- | lib/PublicInbox/WwwListing.pm | 13 |
4 files changed, 11 insertions, 38 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index 9995140c..97bec5e7 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -152,8 +152,7 @@ sub thread_cb { sub thread_mbox { my ($ctx, $over, $sfx) = @_; - eval { require PublicInbox::MboxGz }; - return need_gzip($ctx) if $@; + require PublicInbox::MboxGz; my $msgs = $ctx->{msgs} = $over->get_thread($ctx->{mid}, {}); return [404, [qw(Content-Type text/plain)], []] if !@$msgs; $ctx->{prev} = $msgs->[-1]; @@ -221,8 +220,7 @@ sub results_cb { sub mbox_all { my ($ctx, $query) = @_; - eval { require PublicInbox::MboxGz }; - return need_gzip($ctx) if $@; + require PublicInbox::MboxGz; return mbox_all_ids($ctx) if $query eq ''; my $qopts = $ctx->{qopts} = { mset => 2 }; my $srch = $ctx->{srch} = $ctx->{-inbox}->search or @@ -236,15 +234,4 @@ sub mbox_all { PublicInbox::MboxGz->response($ctx, \&results_cb, 'results-'.$query); } -sub need_gzip { - html_oneshot($_[0], 501, \<<EOF); -<pre>gzipped mbox not available - -The administrator needs to install the Compress::Raw::Zlib Perl module -to support gzipped mboxes. - -<a href="../">Return to index</a></pre> -EOF -} - 1; diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index c79f198b..e9c66cd1 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -38,8 +38,7 @@ NEWNEWS\r LIST ACTIVE ACTIVE.TIMES NEWSGROUPS OVERVIEW.FMT\r HDR\r OVER\r - -my $have_deflate; +COMPRESS DEFLATE\r sub greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) }; @@ -903,7 +902,7 @@ sub cmd_starttls ($) { sub cmd_compress ($$) { my ($self, $alg) = @_; return '503 Only DEFLATE is supported' if uc($alg) ne 'DEFLATE'; - return r502 if $self->compressed || !$have_deflate; + return r502 if $self->compressed; PublicInbox::NNTPdeflate->enable($self); $self->requeue; undef @@ -990,10 +989,4 @@ sub busy { ($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now)); } -# this is an import to prevent "perl -c" from complaining about fields -sub import { - $have_deflate = eval { require PublicInbox::NNTPdeflate } and - $CAPABILITIES .= "COMPRESS DEFLATE\r\n"; -} - 1; diff --git a/lib/PublicInbox/WwwAltId.pm b/lib/PublicInbox/WwwAltId.pm index 630ed686..e5476d1f 100644 --- a/lib/PublicInbox/WwwAltId.pm +++ b/lib/PublicInbox/WwwAltId.pm @@ -8,6 +8,7 @@ use PublicInbox::Qspawn; use PublicInbox::WwwStream qw(html_oneshot); use PublicInbox::AltId; use PublicInbox::Spawn qw(which); +use PublicInbox::GzipFilter; our $sqlite3 = $ENV{SQLITE3}; sub sqlite3_missing ($) { @@ -64,13 +65,6 @@ or EOF } - eval { require PublicInbox::GzipFilter } or - return html_oneshot($ctx, 501, \<<EOF); -<pre>gzip output not available - -The administrator needs to install the Compress::Raw::Zlib Perl module -to support gzipped sqlite3 dumps.</pre> -EOF $sqlite3 //= which('sqlite3'); if (!defined($sqlite3)) { return html_oneshot($ctx, 501, \<<EOF); diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index 42a0c0d8..38a37dda 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -14,14 +14,13 @@ use bytes (); # bytes::length use HTTP::Date qw(time2str); use Digest::SHA (); use File::Spec (); +use IO::Compress::Gzip qw(gzip); *try_cat = \&PublicInbox::Inbox::try_cat; our $json; -if (eval { require IO::Compress::Gzip }) { - for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) { - eval "require $mod" or next; - # ->ascii encodes non-ASCII to "\uXXXX" - $json = $mod->new->ascii(1) and last; - } +for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) { + eval "require $mod" or next; + # ->ascii encodes non-ASCII to "\uXXXX" + $json = $mod->new->ascii(1) and last; } sub list_all_i { @@ -220,7 +219,7 @@ sub js ($$) { $repo->{reference} = $abs2urlpath->{$abs}; } my $out; - IO::Compress::Gzip::gzip(\($json->encode($manifest)) => \$out); + gzip(\($json->encode($manifest)) => \$out); $manifest = undef; [ 200, [ qw(Content-Type application/gzip), 'Last-Modified', time2str($mtime), |