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.
This commit is contained in:
parent
43928b91e8
commit
29dd09e809
1 changed files with 2 additions and 10 deletions
12
FU.pm
12
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<libpq.so> - required for L<FU::Pg>, dynamically loaded through
|
||||
C<dlopen()>.
|
||||
|
||||
=item * L<Compress::Zstd> - to support transparent HTTP compression through
|
||||
Zstandard.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue