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. 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. For "gzip" using indexOf() is OK: It can be "x-gzip" (see 3.1.2.1. Content Codings in RFC7231.) [quote] The following content-coding values are defined by this specification: compress (and x-compress): See Section 4.2.1 of [RFC7230]. deflate: See Section 4.2.2 of [RFC7230]. gzip (and x-gzip): See Section 4.2.3 of [RFC7230]. [/quote] > return false; > } > > > 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... > + </fix> > </changelog> > </subsection> > <subsection name="Coyote"> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org