FU::Util: Add brotli_compress() and use it for FU output compression

Seems to compresses and perform better than libdeflate at level 6, so
certainly worth using.
This commit is contained in:
Yorhel 2025-03-19 10:12:06 +01:00
parent bc33fe53f0
commit 6159b33950
5 changed files with 99 additions and 14 deletions

View file

@ -13,7 +13,7 @@ our @EXPORT_OK = qw/
utf8_decode uri_escape uri_unescape
query_decode query_encode
httpdate_format httpdate_parse
gzip_lib gzip_compress
gzip_lib gzip_compress brotli_compress
fdpass_send fdpass_recv
/;
@ -401,6 +401,8 @@ I<zlib(-ng)> the level is capped at 9. 6 is typically used as a default.
Throws an error if no suitable library was found.
This function is B<NOT> safe to use from multiple threads!
=back
This module does not currently implement decompression. If you need that, or
@ -409,6 +411,22 @@ L<Compress::Raw::Zlib> and L<Compress::Zlib> in the core Perl distribution and
L<Gzip::Deflate> on CPAN.
=head2 Brotli Compression
Just a small wrapper around C<libbrotlienc.so>'s one-shot compression
interface.
=over
=item brotli_compress($level, $data)
Returns a byte string with the brotli-compressed version of C<$data> at the
given quality C<$level> (between 0 and 11).
Throws an error if C<libbrotlienc.so> could not be found or loaded.
=back
=head2 File Descriptor Passing