tomcat
tomcat copied to clipboard
Add configurable compression
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.