feat: support zstd response encoding based on Accept-Encoding#62
Open
mo4islona wants to merge 1 commit into
Open
feat: support zstd response encoding based on Accept-Encoding#62mo4islona wants to merge 1 commit into
mo4islona wants to merge 1 commit into
Conversation
84fa936 to
cfbd04c
Compare
kalabukdima
reviewed
May 6, 2026
| /// See <https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.4> | ||
| /// At equal q, prefers zstd over gzip. | ||
| /// Returns None if neither gzip nor zstd is accepted. | ||
| pub fn from_accept_encoding(header: Option<&str>) -> Option<Self> { |
Contributor
There was a problem hiding this comment.
How is it related to the hotblocks? If axum doesn't support parsing these values, let's not overengineer and just prefer zstd. If it's actually needed, it should be a separate crate outside of this repo
Contributor
Author
There was a problem hiding this comment.
Do you mean we should ignore the q-numbers and check the first header and the first exact match for "zstd"?
Contributor
There was a problem hiding this comment.
Yes, if the client supports zstd, just respond with zstd, otherwise — with gzip
Respect client Accept-Encoding header per RFC 7231: - If client sends Accept-Encoding: zstd → respond with zstd compression - If client sends Accept-Encoding: gzip → respond with gzip (backward compat) - Quality values respected (e.g. "zstd;q=1.0, gzip;q=0.5" → zstd) - At equal q, prefer zstd over gzip - Default to gzip when no Accept-Encoding header present Related: subsquid/squid-sdk#456
cfbd04c to
c27964e
Compare
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.
Summary
zstdinAccept-Encoding, otherwise fall back to gzip (backward compatible default)Vary: Accept-EncodingChanges
crates/hotblocks/src/encoding.rs:ContentEncodingenum (Gzip/Zstd) with a trivialfrom_headerscheckapi.rs: detect encoding from request headers, setcontent-encoding/varyresponse headersrunning.rs:Compressorenum wrappingGzEncoder/ZstdEncoder(level 1), selected per requestresponse.rs,service.rs: pass the encoding through the query pipeline