jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Introduce CompressionHandler to support compression from gzip, brotli, and zstandard

Open joakime opened this issue 3 years ago • 6 comments

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/zstd Media Type

(FYI, curl supports both of these compression types now)

joakime avatar Oct 26 '22 14:10 joakime

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.

github-actions[bot] avatar Oct 27 '23 00:10 github-actions[bot]

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 avatar Apr 25 '24 18:04 joakime

@joakime lets start working on this in the 12.1.x branch

gregw avatar May 26 '24 22:05 gregw

I'm working on this now.

joakime avatar Jun 05 '24 21:06 joakime

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.

joakime avatar Aug 20 '24 19:08 joakime

@gregw lets have a chat about the remaining tasks.

joakime avatar Aug 20 '24 19:08 joakime