fastify / fastify-compress

Fastify compression utils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regarding content encoding priorities in fastify/compress

shishir-karanth opened this issue · comments

💬 Question

Hi. how do I define custom encoding priorities for supported Content-Encoding types in fastify/compress?

The documentation states that I can define my custom encodings array with the priorities but I could not get it to work. Even though I define encodings array as ["gzip", "deflate", "br"] (prefer gzip over deflate and deflate over br), I am still seeing responses compressed using br for the requests with Accept-Encoding: gzip, deflate, br. Any help? Thanks

Your Environment

  • node version: 16
  • fastify version: >=3.0.0
  • os: Windows

Took a look at the fastify/compress code.

Forgive my limited knowledge, but on this line, shouldn't it be sorted over the input encodings array like below?

params.encodings = Array.isArray(opts.encodings) ? supportedEncodings .filter(encoding => opts.encodings.includes(encoding)) .sort((a, b) => opts.encodings.indexOf(a) - opts.encodings.indexOf(b)) : supportedEncodings

commented

Would you like to send a PR to address the issue?

@climba03003 I don't seem to have commit-access to this repository. Can you please help me with the access?

commented

Can you please help me with the access?

  1. Fork the repository
  2. Clone from your fork
  3. Create a new branch based on master
  4. Commit new code
  5. Push the code to your fork
  6. Submit Pull Request on Github