Author: markt Date: Wed Dec 14 11:05:10 2016 New Revision: 1774177 URL: http://svn.apache.org/viewvc?rev=1774177&view=rev Log: Don't duplicate storage of noCompressionUserAgents in the Processor
Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java?rev=1774177&r1=1774176&r2=1774177&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Wed Dec 14 11:05:10 2016 @@ -163,12 +163,36 @@ public abstract class AbstractHttp11Prot public void setCompression(String valueS) { compression = valueS; } - private String noCompressionUserAgents = null; + private Pattern noCompressionUserAgents = null; + /** + * Obtain the String form of the regular expression that defines the user + * agents to not use gzip with. + */ public String getNoCompressionUserAgents() { + if (noCompressionUserAgents == null) { + return null; + } else { + return noCompressionUserAgents.toString(); + } + } + protected Pattern getNoCompressionUserAgentsPattern() { return noCompressionUserAgents; } - public void setNoCompressionUserAgents(String valueS) { - noCompressionUserAgents = valueS; + /** + * Set no compression user agent pattern. Regular expression as supported + * by {@link Pattern}. e.g.: <code>gorilla|desesplorer|tigrus</code>. + * + * @param noCompressionUserAgents The regular expression for user agent + * strings for which compression should not + * be applied + */ + public void setNoCompressionUserAgents(String noCompressionUserAgents) { + if (noCompressionUserAgents == null || noCompressionUserAgents.length() == 0) { + this.noCompressionUserAgents = null; + } else { + this.noCompressionUserAgents = + Pattern.compile(noCompressionUserAgents); + } } @@ -229,8 +253,7 @@ public abstract class AbstractHttp11Prot * "gorilla|desesplorer|tigrus" */ public void setRestrictedUserAgents(String restrictedUserAgents) { - if (restrictedUserAgents == null || - restrictedUserAgents.length() == 0) { + if (restrictedUserAgents == null || restrictedUserAgents.length() == 0) { this.restrictedUserAgents = null; } else { this.restrictedUserAgents = Pattern.compile(restrictedUserAgents); @@ -710,7 +733,6 @@ public abstract class AbstractHttp11Prot processor.setAdapter(getAdapter()); processor.setCompressionMinSize(getCompressionMinSize()); processor.setCompression(getCompression()); - processor.setNoCompressionUserAgents(getNoCompressionUserAgents()); return processor; } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1774177&r1=1774176&r2=1774177&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Wed Dec 14 11:05:10 2016 @@ -141,12 +141,6 @@ public class Http11Processor extends Abs /** - * Regular expression that defines the user agents to not use gzip with - */ - protected Pattern noCompressionUserAgents = null; - - - /** * Host name (used to avoid useless B2C conversion on the host name). */ protected char[] hostNameC = new char[0]; @@ -241,24 +235,6 @@ public class Http11Processor extends Abs /** - * Set no compression user agent pattern. Regular expression as supported - * by {@link Pattern}. e.g.: <code>gorilla|desesplorer|tigrus</code>. - * - * @param noCompressionUserAgents The regular expression for user agent - * strings for which compression should not - * be applied - */ - public void setNoCompressionUserAgents(String noCompressionUserAgents) { - if (noCompressionUserAgents == null || noCompressionUserAgents.length() == 0) { - this.noCompressionUserAgents = null; - } else { - this.noCompressionUserAgents = - Pattern.compile(noCompressionUserAgents); - } - } - - - /** * Return compression level. * * @return The current compression level in string form (off/on/force) @@ -351,12 +327,11 @@ public class Http11Processor extends Abs } // Check for incompatible Browser + Pattern noCompressionUserAgents = protocol.getNoCompressionUserAgentsPattern(); if (noCompressionUserAgents != null) { - MessageBytes userAgentValueMB = - request.getMimeHeaders().getValue("user-agent"); + MessageBytes userAgentValueMB = request.getMimeHeaders().getValue("user-agent"); if(userAgentValueMB != null) { String userAgentValue = userAgentValueMB.toString(); - if (noCompressionUserAgents.matcher(userAgentValue).matches()) { return false; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org