From 29dd09e809e2bbcfbf357a5faec75ffd9b6b946a Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 26 Feb 2025 08:59:33 +0100 Subject: [PATCH] FU: Drop Zstd support Compress::Zstd decided to bundle libzstd instead of linking to the system lib, and it predictably hasn't been updated in 6 years. I consider that broken to the point of DO-NOT-USE. Maybe I'll do a custom dlopen() wrapper for that later, but for now let's just stick with gzip. --- FU.pm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/FU.pm b/FU.pm index 4601423..ce830a6 100644 --- a/FU.pm +++ b/FU.pm @@ -739,7 +739,6 @@ sub _error_page($, $code, $title, $msg) { sub _finalize { state $haszlib = eval { require Compress::Raw::Zlib; 1 }; - state $haszstd = eval { require Compress::Zstd; 1 }; my $r = $FU::REQ; if ($r->{status} == 204 || $r->{status} == 304) { @@ -749,17 +748,13 @@ sub _finalize { $r->{resbody} = ''; } else { - if (($haszlib || $haszstd) && length($r->{resbody}) > 256 + if ($haszlib && length($r->{resbody}) > 256 && !defined $r->{reshdr}{'content-encoding'} && FU::compress_mimes->{$r->{reshdr}{'content-type'}}) { $r->{reshdr}{'vary'} = ($r->{reshdr}{'vary'} ? $r->{reshdr}{'vary'}.', ' : '').'accept-encoding' if ($r->{reshdr}{'vary'}||'') !~ /accept-encoding/i; - if ($haszstd && ($r->{hdr}{'accept-encoding'}||'') =~ /zstd/) { - $r->{resbody} = Compress::Zstd::compress($r->{resbody}); - $r->{reshdr}{'content-encoding'} = 'zstd'; - - } elsif ($haszlib && ($r->{hdr}{'accept-encoding'}||'') =~ /gzip/) { + if ($haszlib && ($r->{hdr}{'accept-encoding'}||'') =~ /gzip/) { # Use lower-level API because the higher-level Compress::Zlib loads a whole bunch of other modules. my $z = Compress::Raw::Zlib::Deflate->new(-WindowBits => Compress::Raw::Zlib::WANT_GZIP(), -Level => 3, -AppendOutput => 1); $z->deflate($r->{resbody}, my $buf); @@ -884,9 +879,6 @@ is). There are a few additional optional dependencies: =item * C - required for L, dynamically loaded through C. -=item * L - to support transparent HTTP compression through -Zstandard. - =back