| 1 |
= cowboy_decompress_h(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
cowboy_decompress_h - Decompress stream handler |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
The module `cowboy_decompress_h` decompresses request bodies |
| 10 |
automatically when the server supports it. |
| 11 |
|
| 12 |
The only compression algorithm currently supported is the |
| 13 |
gzip algorithm. Another limitation is that decompression |
| 14 |
is only attempted when gzip is the only content-encoding |
| 15 |
in the request. |
| 16 |
|
| 17 |
This stream handler always adds a field to the Req object |
| 18 |
with the name `content_decoded` which is treated as a |
| 19 |
list of decoded content-encoding values. Currently this |
| 20 |
list may only contain the `<<"gzip">>` binary if content |
| 21 |
may be decoded; or be empty otherwise. |
| 22 |
|
| 23 |
== Options |
| 24 |
|
| 25 |
[source,erlang] |
| 26 |
---- |
| 27 |
opts() :: #{ |
| 28 |
decompress_enabled => boolean(), |
| 29 |
decompress_ratio_limit => non_neg_integer() |
| 30 |
} |
| 31 |
---- |
| 32 |
|
| 33 |
Configuration for the decompress stream handler. |
| 34 |
|
| 35 |
The default value is given next to the option name: |
| 36 |
|
| 37 |
decompress_ratio_limit (20):: |
| 38 |
The max ratio of the compressed and decompressed body |
| 39 |
before it is rejected with a `413 Payload Too Large` |
| 40 |
error response. |
| 41 |
+ |
| 42 |
This option can be updated at any time using the |
| 43 |
`set_options` stream handler command. |
| 44 |
|
| 45 |
decompress_enabled (true):: |
| 46 |
|
| 47 |
Whether the handler is enabled by default. |
| 48 |
+ |
| 49 |
This option can be updated using the `set_options` |
| 50 |
stream handler command. This allows disabling |
| 51 |
decompression for the current stream. Attempts |
| 52 |
to enable or disable decompression after starting |
| 53 |
to read the body will be ignored. |
| 54 |
+ |
| 55 |
Note that when the handler initialises it removes |
| 56 |
the `content-encoding: gzip` header if any and |
| 57 |
prepares for decompression even when |
| 58 |
`decompress_enabled` is initially set to `false`. |
| 59 |
The `content_decoded` Req object field will |
| 60 |
contain `<<"gzip">>` when that happens. |
| 61 |
|
| 62 |
== Events |
| 63 |
|
| 64 |
The decompress stream handler does not produce any event. |
| 65 |
|
| 66 |
== Changelog |
| 67 |
|
| 68 |
* *2.11*: Module introduced. |
| 69 |
|
| 70 |
== See also |
| 71 |
|
| 72 |
link:man:cowboy(7)[cowboy(7)], |
| 73 |
link:man:cowboy_stream(3)[cowboy_stream(3)], |
| 74 |
link:man:cowboy_compress_h(3)[cowboy_compress_h(3)], |
| 75 |
link:man:cowboy_metrics_h(3)[cowboy_metrics_h(3)], |
| 76 |
link:man:cowboy_stream_h(3)[cowboy_stream_h(3)], |
| 77 |
link:man:cowboy_tracer_h(3)[cowboy_tracer_h(3)] |