Skip to content

Commit b03c67b

Browse files
trizenoalders
authored andcommitted
Support for Brotli encoding
(needs tests) Update Message.pm
1 parent 71fc01b commit b03c67b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/HTTP/Message.pm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ sub decoded_content
302302
$content_ref = \$output;
303303
$content_ref_iscopy++;
304304
}
305+
elsif ($ce eq 'br') {
306+
require IO::Uncompress::Brotli;
307+
my $bro = IO::Uncompress::Brotli->create;
308+
my $output = eval { $bro->decompress($$content_ref) };
309+
$@ and die "Can't unbrotli content: $@";
310+
$content_ref = \$output;
311+
$content_ref_iscopy++;
312+
}
305313
elsif ($ce eq "x-bzip2" or $ce eq "bzip2") {
306314
require IO::Uncompress::Bunzip2;
307315
my $output;
@@ -433,6 +441,10 @@ sub decodable
433441
require IO::Uncompress::Bunzip2;
434442
push(@enc, "x-bzip2", "bzip2");
435443
};
444+
eval {
445+
require IO::Uncompress::Brotli;
446+
push(@enc, 'br');
447+
};
436448
# we don't care about announcing the 'identity', 'base64' and
437449
# 'quoted-printable' stuff
438450
return wantarray ? @enc : join(", ", @enc);

0 commit comments

Comments
 (0)