+
+package PublicInbox::NoopFilter;
+use strict;
+
+sub new { bless \(my $ignore), __PACKAGE__ }
+
+# noop workalike for PublicInbox::GzipFilter methods
+sub translate { $_[1] // '' }
+sub zmore { $_[1] }
+sub zflush { $_[1] // '' }
+1;
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index a3d4e2b3566972796bc6c920568a9a1078d485be..780c97e913b22a9d2427aa4d7cd5a3c80f4a65ea 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -10,6 +10,8 @@ use PublicInbox::Hval qw(ascii_html prurl);
use PublicInbox::Linkify;
use PublicInbox::View;
use PublicInbox::Inbox;
+use PublicInbox::NoopFilter;
+use PublicInbox::GzipFilter qw(gzf_maybe);
use bytes (); # bytes::length
use HTTP::Date qw(time2str);
use Digest::SHA ();
@@ -104,13 +106,15 @@ }
sub html ($$) {
my ($env, $list) = @_;
- my $title = 'public-inbox';
- my $out = '';
+ my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
+ 'Content-Length', undef ];
+ my $gzf = gzf_maybe($h, $env) || PublicInbox::NoopFilter::new();
+ my $out = $gzf->zmore('' .
+ 'public-inbox listing' .
+ '');
my $code = 404;
if (@$list) {
- $title .= ' - listing';
$code = 200;
-
# Schwartzian transform since Inbox->modified is expensive
@$list = sort {
$b->[0] <=> $a->[0]
@@ -118,13 +122,14 @@ } map { [ $_->modified, $_ ] } @$list;
my $tmp = join("\n", map { ibx_entry(@$_, $env) } @$list);
my $l = PublicInbox::Linkify->new;
- $out = ''.$l->to_html($tmp).'
';
+ $out .= $gzf->zmore($l->to_html($tmp));
+ } else {
+ $out .= $gzf->zmore('no inboxes, yet');
}
- $out = "$title" . $out;
- $out .= ''. PublicInbox::WwwStream::code_footer($env) .
- '
';
-
- my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
+ $out .= $gzf->zflush('
'.
+ PublicInbox::WwwStream::code_footer($env) .
+ '
');
+ $h->[3] = bytes::length($out);
[ $code, $h, [ $out ] ];
}
diff --git a/t/www_listing.t b/t/www_listing.t
index 0aededd43ebc669b211ebbd366ec8bec770e85d8..c4511cd1fed11cc46233e24b371b9d5c0f47b7f3 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -35,13 +35,19 @@ 'got fingerprint with non-empty repo');
sub tiny_test {
my ($json, $host, $port) = @_;
+ my $tmp;
my $http = HTTP::Tiny->new;
my $res = $http->get("http://$host:$port/");
is($res->{status}, 200, 'got HTML listing');
like($res->{content}, qr!