X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwStatic.pm;h=29e4819dfc4b51e52fa5d8baec2a1c5ffb7b82f1;hb=af0b0fb7a454470a32c452119d0392e0dedb3fe1;hp=3c933156405bedb92db5afee4a3beed6a29506bc;hpb=6ebcec3add4d6aeff6e3b3eb019a404528c079ec;p=public-inbox.git diff --git a/lib/PublicInbox/WwwStatic.pm b/lib/PublicInbox/WwwStatic.pm index 3c933156..29e4819d 100644 --- a/lib/PublicInbox/WwwStatic.pm +++ b/lib/PublicInbox/WwwStatic.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 all contributors +# Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ # This package can either be a PSGI response body for a static file @@ -17,6 +17,7 @@ use HTTP::Date qw(time2str); use HTTP::Status qw(status_message); use Errno qw(EACCES ENOTDIR ENOENT); use URI::Escape qw(uri_escape_utf8); +use PublicInbox::GzipFilter qw(gzf_maybe); use PublicInbox::Hval qw(ascii_html); use Plack::MIME; our @EXPORT_OK = qw(@NO_CACHE r path_info_raw); @@ -310,12 +311,15 @@ sub dir_response ($$$) { (map { ${$other{$_}} } sort keys %other)); my $path_info_html = ascii_html($path_info); - my $body = "Index of $path_info_html" . + my $h = [qw(Content-Type text/html Content-Length), undef]; + my $gzf = gzf_maybe($h, $env); + $gzf->zmore("Index of $path_info_html" . ${$self->{style}} . - "
Index of $path_info_html

\n";
-	$body .= join("\n", @entries) . "

\n"; - [ 200, [ qw(Content-Type text/html - Content-Length), bytes::length($body) ], [ $body ] ] + "
Index of $path_info_html

\n");
+	$gzf->zmore(join("\n", @entries));
+	my $out = $gzf->zflush("

\n"); + $h->[3] = bytes::length($out); + [ 200, $h, [ $out ] ] } sub call { # PSGI app endpoint