Debian Codegraph @

t/message-brotli.t

raw
1 #! perl -w
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Needs 'IO::Compress::Brotli', 'IO::Uncompress::Brotli';
8
9 require HTTP::Message;
10
11 subtest "decoding" => sub {
12
13 my $m = HTTP::Message->new(
14 [
15 "Content-Type" => "text/plain",
16 "Content-Encoding" => "br, base64",
17 ],
18 "CwaASGVsbG8gd29ybGQhCgM=\n"
19 );
20 is( $m->decoded_content, "Hello world!\n", "decoded_content() works" );
21 ok( $m->decode, "decode() works" );
22 is( $m->content, "Hello world!\n", "... and content() is correct" );
23 };
24
25 subtest "encoding" => sub {
26 my $m = HTTP::Message->new(
27 [
28 "Content-Type" => "text/plain",
29 ],
30 "Hello world!"
31 );
32 ok( $m->encode("br"), "set encoding to 'br" );
33 is( $m->header("Content-Encoding"),
34 "br", "... and Content-Encoding is set" );
35 isnt( $m->content, "Hello world!", "... and the content has changed" );
36 is( $m->decoded_content, "Hello world!", "decoded_content() works" );
37 ok( $m->decode, "decode() works" );
38 is( $m->content, "Hello world!", "... and content() is correct" );
39 };
40
41 done_testing;