inflation icon indicating copy to clipboard operation
inflation copied to clipboard

Support Brotli decompression (content-encoding: br)

Open ide opened this issue 2 years ago • 1 comments

Adds backwards-compatible support for Brotli decompression for versions of Node that natively support Brotli (10.16.0+). For reference, Node LTS is soon to be 14.15.0+ only.

If the version of Node doesn't support Brotli and the request specifies content-encoding: br, an HTTP 415 error is thrown, the exact same as before. If Node does support Brotli, it will use Brotli decompression on the provided stream.

A new option called options.brotli is supported. This way Brotli and Gzip options are kept separate. Only the brotli options are passed to the Brotli decompressor.

Added unit tests for both new and old versions of Node. Added Node 16 to the Travis CI matrix. Tested with Node 8 to ensure we get a 415 status code when Brotli is unsupported and tested with Node 16 to ensure Brotli decompression works when it is supported.

ide avatar Feb 22 '22 01:02 ide

@jonathanong would you be open to reviewing this if you have some time? I know it's been six years since you last worked on this package. I tried to write the code in a way that wouldn't require attention for another six. The motivation for this change is to bring Brotli decompression to koa-body and koa-bodyparser, both of which depend on inflation@^2.0.0 via co-body.

ide avatar Apr 27 '22 06:04 ide