Skip to content

Conversation

@Long9725
Copy link

@Long9725 Long9725 commented Nov 1, 2025

Make compression pluggable and configurable (gzip level/buffer), retain API compatibility

Overview

  • Introduces configurable gzip compression (level, buffer size) and a pluggable output filter factory for HTTP/1.1. Preserves the original API to maintain backward compatibility.

Changes

  • CompressionConfig: add gzipLevel and gzipBufferSize with validation; add configurable noCompressionEncodings; extend useCompression to accept an encoding; restore the original useCompression(Request, Response) overload
    delegating to gzip.
  • AbstractHttp11Protocol: expose getters/setters for gzip settings; add OutputFilterFactory support (by instance and by class name with error handling); delegate compression checks using the factory’s encoding; expose get/
    setNoCompressionEncodings.
  • http11.filters: add OutputFilterFactory interface and default GzipOutputFilterFactory; update GzipOutputFilter to honor level and buffer size.
  • Http11Processor/HTTP2 StreamProcessor: construct gzip filter using protocol-provided level/buffer settings.
  • Tests: update existing tests and add coverage for gzip level/buffer, output filter factory, and no-compression encodings.
  • Docs/I18N: document gzipLevel, gzipBufferSize and noCompressionEncodings in webapps/docs/config/http.xml; add related LocalStrings messages.

Influence

  • Compatibility: no breaking changes; existing behavior remains default (gzip enabled per prior rules, default level -1, buffer 512).
  • Extensibility: allows custom compression filters and fine-tuned gzip settings; avoids double-compression via configurable encodings.
  • Risk: low; validated by added/updated unit tests.

Copy link
Contributor

@markt-asf markt-asf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing the PR. It has been very thought provoking.

I think we need to look at more than just GZip. Other compression algorithms are available and I think we need a more generic approach. I don't think we should be setting algorithm specific settings in the Protocol. I also don't think they should be set on CompressionCongfig. Speaking of CompressionConfig, are the new getters there used? I looked but couldn't see any calls to them.

I think we might need a new server.xml element for output compression (and possibly one for input compression too). With attributes for className, encoding and algorithm specific attributes. It should be possible to override the default gzip support.

The handling of custom InputFilters might provide some inspiration for OutputFilters.

There are some elements of the PR that can be used as is. I'll start cherry-picking those shortly.

markt-asf added a commit that referenced this pull request Feb 6, 2026
This can be used to control which content encodings will not be
compressed when compression is enabled.
Based on pull request #914 by Long9725.
markt-asf added a commit that referenced this pull request Feb 6, 2026
This can be used to control which content encodings will not be
compressed when compression is enabled.
Based on pull request #914 by Long9725.
markt-asf added a commit that referenced this pull request Feb 6, 2026
This can be used to control which content encodings will not be
compressed when compression is enabled.
Based on pull request #914 by Long9725.
markt-asf added a commit that referenced this pull request Feb 6, 2026
This can be used to control which content encodings will not be
compressed when compression is enabled.
Based on pull request #914 by Long9725.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants