PlugCaisson behaviour (plug_caisson v0.1.0)
Body reader for supporting compressed Plug
requests.
Summary
Callbacks
deinit(state)
init(opts)
process(state, data, opts)
Functions
read_body(conn, opts \\ [])
Read Plug.Conn
request body and decompress it if needed.
Options
Accepts the same set of options as Plug.Conn.read_body/2
with one option
extra: :algorithms
which is map containing algorithm identifier as key and
tuple containing module name for module that implements PlugCaisson
behaviour and value that will be passed as 2nd argument to the c:decompress/2
callback.
By default the value is set to:
%{
"br" => {PlugCaisson.Brotli, []},
"deflate" => {PlugCaisson.Zlib, [type: :deflate]},
"gzip" => {PlugCaisson.Zlib, [type: :gzip]},
"zstd" => {PlugCaisson.Zstandard, []}
}
Supported algorithms
gzip
deflate
br
(Brotli) - only if:brotli
dependency is availablezstd
(Zstandard) - only if:ezstd
dependency is available
Options
All passed opts will be passed to Plug.Conn.read_body/2
and to used
decompression handlers. Decompressors by default will use :length
to limit
amount of returned data to prevent zipbombs. Returned data can be longer than
:length
if the internal decompression buffer was larger. As it is described
in Plug.Conn.read_body/2
docs. By default length: 8_000_000
.