about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwText.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-05 23:27:55 +0000
committerEric Wong <e@yhbt.net>2020-07-06 20:01:15 +0000
commit6bcab55b2594368e5f8aad0badb8d51d5d8ba20f (patch)
treeb110631095f1e8229231c8527bd5308f731576f1 /lib/PublicInbox/WwwText.pm
parentba212558b86874d197c86e2acd0776b5b095ee5b (diff)
downloadpublic-inbox-6bcab55b2594368e5f8aad0badb8d51d5d8ba20f.tar.gz
gzf_maybe always returns a GzipFilter object, even if it uses
CompressNoop.  We can also use ->zflush instead of
->translate(undef) here for the final bit.
Diffstat (limited to 'lib/PublicInbox/WwwText.pm')
-rw-r--r--lib/PublicInbox/WwwText.pm15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index 08691684..a691e2d8 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -38,16 +38,13 @@ sub get_text {
         }
         my $env = $ctx->{env};
         if ($raw) {
-                my $body;
-                if (my $gzf = $code == 200 ? gzf_maybe($hdr, $env) : undef) {
-                        my $zbuf = $gzf->translate($txt);
-                        undef $txt;
-                        $body = [ $zbuf .= $gzf->translate(undef) ];
-                } else {
-                        $body = [ $txt ];
+                if ($code == 200) {
+                        my $gzf = gzf_maybe($hdr, $env);
+                        $txt = $gzf->translate($txt);
+                        $txt .= $gzf->zflush;
                 }
-                $hdr->[3] = bytes::length($body->[0]);
-                return [ $code, $hdr, $body ]
+                $hdr->[3] = bytes::length($txt);
+                return [ $code, $hdr, [ $txt ] ]
         }
 
         # enforce trailing slash for "wget -r" compatibility