fix(brotli-plugin): Skip brotli compression for upstream compressed response#10740
Merged
juststillthinking merged 12 commits intoJan 12, 2024
Merged
Conversation
SilentEntity
marked this pull request as ready for review
January 3, 2024 05:29
Contributor
|
Could you add some test cases? |
Contributor
|
I think it's reasonable, multiple compressions may cause unnecessary trouble |
Contributor
|
please make the ci pass |
Contributor
Author
|
okay, it's ready |
Contributor
Author
|
The typo is fixed. It will pass in CI. |
Contributor
|
The ci still failed |
Contributor
Author
|
Hi @monkeyDluffy6017, please check now |
juststillthinking
approved these changes
Jan 11, 2024
AlinsRan
approved these changes
Jan 12, 2024
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.
Skipping the
brotlicompression if the upstream response is already compressed.The Problem
The problem occurs when the upstream service sends compressed data/response either in
gzipordeflate. Apisix tries to compress data inbrotliwhich is already compressed and, in turn, returns encoded data that can not be used by the browser or application.Possible Solutions
There are two options to solve the problem first to skip the further compression and return with the upstream compressed response. The second is to decompress the upstream response and then compress using
brotli, which is not viable on apisix gateway, it increases the overhead of the gateway and results in increasing latency and computation requirements.This PR solves the Issue by skipping the
brotlicompression if the upstream response is compressed.Checklist