fix brotli responses being double-compressed#166
Merged
mcollina merged 1 commit intofastify:masterfrom May 18, 2021
Merged
Conversation
mcollina
reviewed
May 17, 2021
| // response is already compressed | ||
| return next() | ||
| } | ||
| setVaryHeader(reply) |
Member
There was a problem hiding this comment.
Should the new block be after setting the setVaryHeader.
Contributor
Author
There was a problem hiding this comment.
Shouldn't fastify-static be responsible for setting the Vary header?
Member
There was a problem hiding this comment.
I don't understand the answer. Anyway I'm landing - if it becomes a problem I guess we'll get another PR.
Member
|
Unfortunately I landed without the test passing. I'm going to rever the commit, would you mind sending a fresh PR? Thanks! |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to fastify/fastify-static#158
When used with fastify-static's
preCompressedoption, this plugin will double-compress.brfiles.Currently this plugin avoids double-compressing for gzip and deflate, by inspecting the magic number in few bytes of the stream. However Brotli doesn't have a magic number to look for.
fastify-compress/index.js
Lines 491 to 494 in 714e4a9
fastify-compress/index.js
Lines 460 to 465 in 714e4a9
Instead we can check for an existing
Content-Encodingheader on the reply. This has the extra advantage that we don't need to strip off theContent-Lengthheader.Checklist
npm run testandnpm run benchmarkand the Code of conduct