arturobernalg opened a new pull request, #1173:
URL: https://github.com/apache/tomcat/pull/1173

   Adds a `compressionBrotliQuality` attribute to the HTTP/1.1 connectors. When 
it is set to 0 to 11, a response is compressed with Brotli instead of gzip if 
the client accepts it and prefers it, taking the `q` values of 
`Accept-Encoding` into account. Otherwise gzip is used, or the response is not 
compressed, exactly as before. The default is `-1`, which keeps the current 
behaviour. HTTP/1.1 and HTTP/2 share the negotiation in `CompressionConfig` and 
the new `BrotliOutputFilter`.
   
   Tomcat has no Brotli encoder, so this uses `libbrotlienc` of the operating 
system through the FFM API. It is optional and is built and loaded as the FFM 
support for OpenSSL is (`tomcat-coyote-ffm.jar`, compiled for the release Java 
version, loaded by reflection). `build.xml` and the bnd file list the new 
package. If the library or FFM can not be used, a warning is logged and gzip is 
used.
   
   The encoder memory is not managed by the JVM, so it is released as soon as 
it is no longer needed: when the response ends, when compression fails, when 
the filter is recycled and, for HTTP/2, when the stream is recycled, which 
HTTP/2 did not do for filters. If compression fails the response is aborted, as 
with gzip, rather than ended as if it were complete. The quality is read once, 
when Brotli is chosen, and is kept with the response so a change to the 
configuration, e.g. with JMX, can not give an invalid quality. A `Cleaner` is 
only a fallback.
   
   Tests: `TestCompressionConfigBrotli`, `TestBrotliOutputFilter`, 
`TestBrotliCompression`, `TestHttp2OutputBuffer` and 
`TestStreamProcessorBrotli`. The Brotli tests are skipped if the library or FFM 
is not available. Also run against a running Tomcat with HTTP/1.1 and HTTP/2, 
comparing the decompressed bytes with the original, including repeated 
`RST_STREAM`, async timeouts and client disconnects, and with the library 
missing or native access denied.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] Add support for Br... arturobernalg (via GitHub) via dev

Reply via email to