You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(codec): respect server's enabled encodings when selecting response compression
`CompressionEncoding::from_accept_encoding_header` picks an encoding
from the client's `grpc-accept-encoding` header gated only on
`cfg(feature = ...)`, not on whether the server actually enabled that
encoding via `.send_compressed(...)`. A server configured for Zstd
would gzip every response whenever a client listed `gzip` before
`zstd` in `grpc-accept-encoding` -- even though the server never
asked for gzip and would not have advertised it in
`into_accept_encoding_header_value`. The sibling
`from_encoding_header` already guards each match arm on
`enabled_encodings.is_enabled(...)`; this fix brings the accept-side
in line.
Observed in production: tonic 0.14.6 server set to
`send_compressed(Zstd)` only, clients sending `gzip,zstd,identity`,
~38% of server CPU spent in `miniz_oxide::deflate`.
Adds three unit tests covering:
* server-only-Zstd, client lists gzip first -> picks Zstd
* no overlap between server and client lists -> picks None
* both enabled, client prefers gzip -> picks Gzip
Copy file name to clipboardExpand all lines: tonic/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Fixed
11
+
12
+
-*(codec)* respect server's enabled encodings when selecting response compression, fixing a case where a server configured with `send_compressed(Zstd)` would still gzip responses when the client listed `gzip` before `zstd` in `grpc-accept-encoding`
0 commit comments