Repository navigation
Add zstd http content compression support - #11470
Merged
Merged
Conversation
Signed-off-by: xingrufei <[email protected]>
hyperxpro
reviewed
Jul 9, 2021
hyperxpro
reviewed
Jul 9, 2021
| /** | ||
| * @see ZstdOptions(int) | ||
| */ | ||
| public static ZstdOptions zstd(int compressionLevel) { |
Signed-off-by: xingrufei <[email protected]>
hyperxpro
reviewed
Jul 9, 2021
| * @param compressionLevel | ||
| */ | ||
| ZstdOptions(int compressionLevel) { | ||
| this.compressionLevel = ObjectUtil.checkPositive(compressionLevel, "compressionLevel"); |
Contributor
There was a problem hiding this comment.
There must be some range of this. You should use ObjectUtils#checkInRange.
normanmaurer
force-pushed
the
add_zstd_http_content
branch
from
July 9, 2021 04:54
ba1173f to
79de381
Compare
Member
|
rebased ... |
Signed-off-by: xingrufei <[email protected]>
…netty into add_zstd_http_content � Conflicts: � codec/src/main/java/io/netty/handler/codec/compression/StandardCompressionOptions.java � codec/src/main/java/io/netty/handler/codec/compression/ZstdOptions.java
Signed-off-by: xingrufei <[email protected]>
Signed-off-by: xingrufei <[email protected]>
Signed-off-by: xingrufei <[email protected]>
trustin
reviewed
Jul 9, 2021
Signed-off-by: xingrufei <[email protected]>
normanmaurer
requested changes
Jul 9, 2021
normanmaurer
left a comment
Member
There was a problem hiding this comment.
One nit... after that is addressed its ready to go
Signed-off-by: xingrufei <[email protected]>
normanmaurer
approved these changes
Jul 9, 2021
hyperxpro
approved these changes
Jul 9, 2021
normanmaurer
approved these changes
Jul 12, 2021
Member
|
@skyguard1 thanks a lot! |
Contributor
Author
|
@normanmaurer It is my pleasure |
normanmaurer
pushed a commit
that referenced
this pull request
Jul 12, 2021
Motivation: netty needs to support zstd content-encoding http content compression Modification: Add ZstdOptions, and modify HttpContentCompressor and CompressorHttp2ConnectionEncoder to support zstd compression Result: netty supports zstd http content compression Signed-off-by: xingrufei <[email protected]>
raidyue
pushed a commit
to raidyue/netty
that referenced
this pull request
Jul 8, 2022
Motivation: netty needs to support zstd content-encoding http content compression Modification: Add ZstdOptions, and modify HttpContentCompressor and CompressorHttp2ConnectionEncoder to support zstd compression Result: netty supports zstd http content compression Signed-off-by: xingrufei <[email protected]>
normanmaurer
added a commit
that referenced
this pull request
Nov 5, 2026
#17726) Motivation: `HttpContentCompressor.determineEncoding(...)` parses the qvalue of every coding in `Accept-Encoding` correctly, but then only compares each coding with the next one in the list `br, zstd, snappy, gzip, deflate` (`brQ >= zstdQ`, `zstdQ >= snappyQ`, ...). That pairwise rule was right when only gzip and deflate existed (`determineWrapper(...)`), but with five codings it picks a coding the client ranked lower, or did not accept at all: | `Accept-Encoding` | configured | selected now | expected | |---|---|---|---| | `br;q=0, gzip` | default, Brotli on the class path | `br` | `gzip` | | `gzip, br;q=0` | default, Brotli on the class path | `br` | `gzip` | | `zstd;q=0, gzip` | default, zstd-jni on the class path | `zstd` | `gzip` | | `snappy;q=0, deflate` | default | `snappy` | `deflate` | | `br;q=0, zstd;q=0, snappy;q=0, gzip;q=0, deflate` | default, Brotli on the class path | `br` | `deflate` | | `br;q=0.1, gzip` | default, Brotli on the class path | `br` | `gzip` | [RFC 9110, Section 12.4.2](https://www.rfc-editor.org/rfc/rfc9110#section-12.4.2): "a value of 0 means "not acceptable"", and [Section 12.5.3](https://www.rfc-editor.org/rfc/rfc9110#section-12.5.3): a listed content coding is acceptable "unless it is accompanied by a qvalue of 0". A client that sends `br;q=0` (for example because it cannot decode Brotli) gets a Brotli body it cannot decode. The pairwise comparisons came with the additions of br (#11256), zstd (#11470) and snappy (#13529); the existing tests only cover single codings and equal qvalues. Modification: - Select the configured coding with the highest qvalue above 0. If qvalues are equal, keep the existing order `br, zstd, snappy, gzip, deflate` (so `"gzip, br"` still gives `br`). The `*` handling and the parsing are unchanged. - Add `testDetermineEncodingHonoursQValues` (gzip, deflate and snappy configured, runs everywhere) and `testDetermineEncodingHonoursQValuesBrotli` (`@EnabledIf("isBrotliAvailable")`) as `@ParameterizedTest`s. - Update `HttpContentCompressorOptionsTest`: `"br; q=0, deflate"` (and the same for zstd and snappy) now selects `deflate`, as the listed coding has qvalue 0. Result: The compressor no longer uses a content coding the client marked as not acceptable, and prefers the coding with the higher qvalue. Requests whose explicitly listed codings have equal qvalues, and requests that only use `*`, give the same result as before. --------- Co-authored-by: Norman Maurer <[email protected]>
chrisvest
pushed a commit
that referenced
this pull request
Nov 5, 2026
…content encoding (#18285) Auto-port of #17726 to 5.0 Cherry-picked commit: 5a638e4 --- Motivation: `HttpContentCompressor.determineEncoding(...)` parses the qvalue of every coding in `Accept-Encoding` correctly, but then only compares each coding with the next one in the list `br, zstd, snappy, gzip, deflate` (`brQ >= zstdQ`, `zstdQ >= snappyQ`, ...). That pairwise rule was right when only gzip and deflate existed (`determineWrapper(...)`), but with five codings it picks a coding the client ranked lower, or did not accept at all: | `Accept-Encoding` | configured | selected now | expected | |---|---|---|---| | `br;q=0, gzip` | default, Brotli on the class path | `br` | `gzip` | | `gzip, br;q=0` | default, Brotli on the class path | `br` | `gzip` | | `zstd;q=0, gzip` | default, zstd-jni on the class path | `zstd` | `gzip` | | `snappy;q=0, deflate` | default | `snappy` | `deflate` | | `br;q=0, zstd;q=0, snappy;q=0, gzip;q=0, deflate` | default, Brotli on the class path | `br` | `deflate` | | `br;q=0.1, gzip` | default, Brotli on the class path | `br` | `gzip` | [RFC 9110, Section 12.4.2](https://www.rfc-editor.org/rfc/rfc9110#section-12.4.2): "a value of 0 means "not acceptable"", and [Section 12.5.3](https://www.rfc-editor.org/rfc/rfc9110#section-12.5.3): a listed content coding is acceptable "unless it is accompanied by a qvalue of 0". A client that sends `br;q=0` (for example because it cannot decode Brotli) gets a Brotli body it cannot decode. The pairwise comparisons came with the additions of br (#11256), zstd (#11470) and snappy (#13529); the existing tests only cover single codings and equal qvalues. Modification: - Select the configured coding with the highest qvalue above 0. If qvalues are equal, keep the existing order `br, zstd, snappy, gzip, deflate` (so `"gzip, br"` still gives `br`). The `*` handling and the parsing are unchanged. - Add `testDetermineEncodingHonoursQValues` (gzip, deflate and snappy configured, runs everywhere) and `testDetermineEncodingHonoursQValuesBrotli` (`@EnabledIf("isBrotliAvailable")`) as `@ParameterizedTest`s. - Update `HttpContentCompressorOptionsTest`: `"br; q=0, deflate"` (and the same for zstd and snappy) now selects `deflate`, as the listed coding has qvalue 0. Result: The compressor no longer uses a content coding the client marked as not acceptable, and prefers the coding with the higher qvalue. Requests whose explicitly listed codings have equal qvalues, and requests that only use `*`, give the same result as before. - `HttpContentCompressorTest`, `HttpContentEncoderTest`, `HttpContentDecompressorTest` pass (63 tests), and `HttpContentCompressorOptionsTest` passes (4). Without the change to `HttpContentCompressor`, 7 of the 13 new cases fail; the others pass both ways. - Checkstyle and revapi pass. The selection was also modelled in Lean 4 against the RFC 9110 rule: for every combination of qvalues from {absent, 0, 0.5, 1} for the five codings and `*`, and every subset of configured codings with qvalues from {absent, 0, 1}, the new selection only returns an acceptable coding with the highest qvalue, and it returns the same coding as before whenever the current result already satisfied that. The change was prepared with Claude Code (Claude Opus 5.5), and the commit has a `Co-Authored-By` trailer. _Prepared with Claude Code on behalf of allthingssecurity._ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: allthingssecurity <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
ikpil
added a commit
to ikpil/Netty.NET
that referenced
this pull request
Nov 29, 2026
…ent encoding (netty/netty#17726) Motivation: `HttpContentCompressor.determineEncoding(...)` parses the qvalue of every coding in `Accept-Encoding` correctly, but then only compares each coding with the next one in the list `br, zstd, snappy, gzip, deflate` (`brQ >= zstdQ`, `zstdQ >= snappyQ`, ...). That pairwise rule was right when only gzip and deflate existed (`determineWrapper(...)`), but with five codings it picks a coding the client ranked lower, or did not accept at all: | `Accept-Encoding` | configured | selected now | expected | |---|---|---|---| | `br;q=0, gzip` | default, Brotli on the class path | `br` | `gzip` | | `gzip, br;q=0` | default, Brotli on the class path | `br` | `gzip` | | `zstd;q=0, gzip` | default, zstd-jni on the class path | `zstd` | `gzip` | | `snappy;q=0, deflate` | default | `snappy` | `deflate` | | `br;q=0, zstd;q=0, snappy;q=0, gzip;q=0, deflate` | default, Brotli on the class path | `br` | `deflate` | | `br;q=0.1, gzip` | default, Brotli on the class path | `br` | `gzip` | [RFC 9110, Section 12.4.2](https://www.rfc-editor.org/rfc/rfc9110#section-12.4.2): "a value of 0 means "not acceptable"", and [Section 12.5.3](https://www.rfc-editor.org/rfc/rfc9110#section-12.5.3): a listed content coding is acceptable "unless it is accompanied by a qvalue of 0". A client that sends `br;q=0` (for example because it cannot decode Brotli) gets a Brotli body it cannot decode. The pairwise comparisons came with the additions of br (netty/netty#11256), zstd (netty/netty#11470) and snappy (netty/netty#13529); the existing tests only cover single codings and equal qvalues. Modification: - Select the configured coding with the highest qvalue above 0. If qvalues are equal, keep the existing order `br, zstd, snappy, gzip, deflate` (so `"gzip, br"` still gives `br`). The `*` handling and the parsing are unchanged. - Add `testDetermineEncodingHonoursQValues` (gzip, deflate and snappy configured, runs everywhere) and `testDetermineEncodingHonoursQValuesBrotli` (`@EnabledIf("isBrotliAvailable")`) as `@ParameterizedTest`s. - Update `HttpContentCompressorOptionsTest`: `"br; q=0, deflate"` (and the same for zstd and snappy) now selects `deflate`, as the listed coding has qvalue 0. Result: The compressor no longer uses a content coding the client marked as not acceptable, and prefers the coding with the higher qvalue. Requests whose explicitly listed codings have equal qvalues, and requests that only use `*`, give the same result as before. --------- Co-authored-by: Norman Maurer <[email protected]> Upstream-Commit: netty/netty@5a638e4
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.
Motivation:
netty needs to support zstd content-encoding http content compression
Modification:
Add ZstdOptions, and modify HttpContentCompressor and CompressorHttp2ConnectionEncoder to support zstd compression
Result:
netty supports zstd http content compression