1IO::Compress::Brotli(3)User Contributed Perl DocumentatioInO::Compress::Brotli(3)
2
3
4
6 IO::Compress::Brotli - Write Brotli buffers/streams
7
9 use IO::Compress::Brotli;
10
11 # compress a buffer
12 my $encoded = bro $encoded;
13
14 # compress a stream
15 my $bro = IO::Compress::Brotli->create;
16 while(have_input()) {
17 my $block = get_input_block();
18 my $encoded_block = $bro->compress($block);
19 handle_output_block($encoded_block);
20 }
21 # Need to finish the steam
22 handle_output_block($bro->finish());
23
25 IO::Compress::Brotli is a module that compressed Brotli buffers and
26 streams. Despite its name, it is not a subclass of IO::Compress::Base
27 and does not implement its interface. This will be rectified in a
28 future release.
29
30 One-shot interface
31 If you have the whole buffer in a Perl scalar use the bro function.
32
33 bro($input)
34 Takes a whole uncompressed buffer as input and returns the
35 compressed data.
36
37 Exported by default.
38
39 Streaming interface
40 If you want to process the data in blocks use the object oriented
41 interface. The available methods are:
42
43 IO::Compress::Brotli->create
44 Returns a IO::Compress::Brotli instance. Please note that a single
45 instance cannot be used to decompress multiple streams.
46
47 $bro->window($window)
48 Sets the window parameter on the brotli encoder. Defaults to
49 BROTLI_DEFAULT_WINDOW (22).
50
51 $bro->quality($quality)
52 Sets the quality paremeter on the brotli encoder. Defaults to
53 BROTLI_DEFAULT_QUALITY (11).
54
55 $bro->mode($mode)
56 Sets the brotli encoder mode, which can be any of "generic", "text"
57 or "font". Defaults to "generic".
58
59 $bro->compress($block)
60 Takes the a block of uncompressed data and returns a block of
61 compressed data. Dies on error.
62
63 $bro->flush()
64 Flushes any pending output from the encoder.
65
66 $bro->finish()
67 Tells the encoder to start the finish operation, and flushes any
68 remaining compressed output.
69
70 Once finish is called, the encoder cannot be used to compress any
71 more content.
72
73 NOTE: Calling finish is required, or the output might remain
74 unflushed, and the be missing termination marks.
75
77 Brotli Compressed Data Format Internet-Draft:
78 <https://www.ietf.org/id/draft-alakuijala-brotli-08.txt>
79
80 Brotli source code: <https://github.com/google/brotli/>
81
83 Marius Gavrilescu, <marius@ieval.ro>
84
85 The encoder bindings, modernisation of the decoder bindings and a clean
86 up of the overall project were contributed by:
87
88 Quim Rovira, <quim@rovira.cat>
89 Ævar Arnfjörð Bjarmason, <avarab@gmail.com>
90 Marcell Szathmári
91 Mattia Barbon, <mattia@barbon.org>
92
94 Copyright (C) 2015-2018 by Marius Gavrilescu
95
96 This library is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself, either Perl version 5.20.2 or, at
98 your option, any later version of Perl 5 you may have available.
99
100
101
102perl v5.36.0 2022-08-16 IO::Compress::Brotli(3)