jetty.project
jetty.project copied to clipboard
Introduce CompressionHandler to support compression from gzip, brotli, and zstandard
Jetty version(s) Jetty 12
Enhancement Description
The current GzipHandler does a good job at handling Content-Encoding: gzip (and Accept-Encoding: gzip), but we shouldn't hardcode only gzip support.
Can we refactor the existing GzipHandler to be more generic, something like DynamicCompressionHandler and have the Gzip support (courtesy of the existing GzipRequest object) just be loaded via a ServiceLoader?
This way we can encourage other compression algorithms under the same Accept-Encoding / Content-Encoding / already compressed rules that the existing codebase handles for us?
Other compression algorithms that have been requested in our issue tracker.
- #2553 - RFC 7932 - Brotli Compressed Data Format
- #6600 - RFC 8878 - Zstandard Compression and the
application/zstdMedia Type
(FYI, curl supports both of these compression types now)
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
When we do this we need to keep in mind the effort for Compression Dictionary Transport.
- https://github.com/WICG/compression-dictionary-transport
- https://datatracker.ietf.org/doc/draft-ietf-httpbis-compression-dictionary/
- https://chromestatus.com/feature/5124977788977152
@joakime lets start working on this in the 12.1.x branch
I'm working on this now.
I've got the basics of the Compression API done.
Including the Encoders as Content.Sink, and Decoders as Content.Source.
The DynamicCompressionHandler (needs a new name, perhaps CompressionHandler ?) can do the basics right now.
What's left ...
- [ ] CompressionHandler Config
- [x] Encoder Config
- [x] Decoder Config
- [ ] Compressions (plural) as single object to find/use/manage all compressions available (ServiceLoader? bean on Server? bean on Client?)
- [ ] Dictionary Support for Encoders and Decoders
- [ ] HTTP Shared Dictionary support in CompressionHandler - see https://datatracker.ietf.org/doc/draft-ietf-httpbis-compression-dictionary/
- [ ] jetty start modules for CompressionHandler
- [ ] XML examples of configuration of CompressionHandler with examples:
- [ ] More testing around error handling of failures during Encoder / Decoder with a focus on cleanup / release.
- [x] Decide if we want to support multiple entire encodings on Decoder or not (I vaguely recall this coming up for GzipHandler where the content was 2 entire Gzip blocks, with headers + data + trailers, one after the other, but coalesced into a single decode. This is awkward at best for Gzip, and totally not supported for brotli and zstandard)
- [ ] Documentation for all of the above.
@gregw lets have a chat about the remaining tasks.