tower-rs / tower-rs/tower-http
Compression encoding preference
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 913
- Forks
- 231
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 8
Description
Feature Request
Motivation
Currently, when using Firefox for example, the encoding used by CompressionLayer is GZIP, which is unfortunate, considering that Brotli produces far smaller files and Firefox does support it.
Proposal
Currently the encoding used by CompressionLayer, is the first one listed in Accept-Encoding, which, as far as I can tell, is not mandated by the specification, see RFC 9110 Section 12.5.3 and 8.4.1.
Furthermore, most servers don't handle it this way and just pick the one from the list they prefer the most. When clients want to specify which one they prefer, they have to use quality values, which is already supported by CompressionLayer (as far as I can tell).
So my proposal is:
- Specify a default server preference for each encoding instead of picking the first one.
- Expose an interface to let the user specify a preference.
Happy to make a PR of course.
Alternatives
For example, if Brotli is the encoding preferred, users could always just only enable that crate feature, considering Brotli is widely supported. Obviously this isn't ideal.
Otherwise implementing CompressionLayer by hand always works.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading CompressionLayer's current Accept-Encoding negotiation and its existing quality-value handling. Define how server-side preferences and a user-facing preference interface should interact. Done means supported encodings are selected by the configured server preference rather than list order, while client quality values remain respected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100