On 15/02/18 13:14, Konstantin Kolinko wrote: > 2018-02-15 14:38 GMT+03:00 <ma...@apache.org>: >> Author: markt >> Date: Thu Feb 15 11:38:11 2018 >> New Revision: 1824297 >> >> URL: http://svn.apache.org/viewvc?rev=1824297&view=rev >> Log: >> Prevent Tomcat from applying gzip compression to content that is already >> compressed with brotli compression. >> Patch provided by burka. >> This closes #99 >> >> Modified: >> tomcat/trunk/java/org/apache/coyote/CompressionConfig.java >> tomcat/trunk/webapps/docs/changelog.xml >> >> Modified: tomcat/trunk/java/org/apache/coyote/CompressionConfig.java >> URL: >> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/CompressionConfig.java?rev=1824297&r1=1824296&r2=1824297&view=diff >> ============================================================================== >> --- tomcat/trunk/java/org/apache/coyote/CompressionConfig.java (original) >> +++ tomcat/trunk/java/org/apache/coyote/CompressionConfig.java Thu Feb 15 >> 11:38:11 2018 >> @@ -186,9 +186,10 @@ public class CompressionConfig { >> >> MimeHeaders responseHeaders = response.getMimeHeaders(); >> >> - // Check if content is not already gzipped >> + // Check if content is not already compressed >> MessageBytes contentEncodingMB = >> responseHeaders.getValue("Content-Encoding"); >> - if ((contentEncodingMB != null) && >> (contentEncodingMB.indexOf("gzip") != -1)) { >> + if ((contentEncodingMB != null) && >> (contentEncodingMB.indexOf("gzip") != -1) && >> + (contentEncodingMB.indexOf("br") != -1)) { > > 1) Wrong. Causes regression. It should be ( != -1 || != -1). Either > one is enough to skip compression.
Whoops. I'll fix that. > 2) "indexOf(br)" sounds weak, there can be false positives. But not > much of a problem: it would result in serving content as > non-compresses, it does not break the content. I did think about that. There aren't that many likely values in Content-Encoding [1] and none of them conflict with the use of "br". >> Modified: tomcat/trunk/webapps/docs/changelog.xml >> URL: >> http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1824297&r1=1824296&r2=1824297&view=diff >> ============================================================================== >> --- tomcat/trunk/webapps/docs/changelog.xml (original) >> +++ tomcat/trunk/webapps/docs/changelog.xml Thu Feb 15 11:38:11 2018 >> @@ -60,6 +60,10 @@ >> specific error codes and/or exception types with the >> <code>ErrorReportValve</code>. (markt) >> </add> >> + <fix> >> + Prevent Tomcat from applying gzip compression to content that is >> already >> + compressed with brotli compression. Patch provided by burka. (markt) > > Based on patch provided... Ack. Mark [1] https://www.iana.org/assignments/http-parameters/http-parameters.xml#http-parameters-1 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org