Re-add gzip compression of HTTP server responses #6699
Merged
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.
Summary
References #4921
This PR reintroduces the
gzip
compression of server responses, if the client signals that it supports it. We had this functionality by default between 2019 and 2021 as part of the stack, but it was removed as part of the Echo framework removal, and never reintroduced back, until now.On the client side we now have support for
zstd
as well. Should we have any regressions related to this reintroduction, we can disable both client and server side support using an experimental feature flag.If the changes are accepted, the experimental flags should be removed as part of the
v3.29.0
release.Changes
gzip
andzstd
compression of server responses.gzip
compression of server responses.Testing
Local testing of the stack. One can manually check that the server side compression is working by looking in the browser developer tools network tab:
Notice that the amount transferred is lower than the content size, and that the
Content-Encoding
is set togzip
.Regressions
Our first public v3 bug report (#82, followed up by #84) was related to
gzip
compression due to a mis-chaining ofFlush
calls - this bug does not exist ingzhttp
, so we are safe.A second consideration is BREACH - in short, we don't really reflect user input into API call contents, such that the compressed result size could leak something about page contents. Our CSRF tokens are also generated on a per request basis, so you cannot brute force the CSRF token by repeatedly loading the page.
gzhttp
is capable of using HTB, which is a general purpose amelioration of the BREACH attack, but it seems that it breaksContent-Type
detection so until that issue is cleared up we'll not enable the random content padding.Notes for Reviewers
The experimental tracking issues will be created after the PR is merged.
Checklist
README.md
for the chosen target branch.CHANGELOG.md
.CONTRIBUTING.md
, there are no fixup commits left.