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
Would you like to send a PR to address the issue?
Sure!
@climba03003 I don't seem to have commit-access to this repository. Can you please help me with the access?
Can you please help me with the access?
- Fork the repository
- Clone from your fork
- Create a new branch based on
master
- Commit new code
- Push the code to your fork
- Submit Pull Request on Github