You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/12/14 11:04:27 UTC
svn commit: r1774171 - in /tomcat/trunk/java/org/apache/coyote/http11:
AbstractHttp11Protocol.java Http11Processor.java
Author: markt
Date: Wed Dec 14 11:04:27 2016
New Revision: 1774171
URL: http://svn.apache.org/viewvc?rev=1774171&view=rev
Log:
Don't duplicate storage of restrictedUserAgents 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=1774171&r1=1774170&r2=1774171&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:04:27 2016
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
import javax.servlet.http.HttpUpgradeHandler;
@@ -201,10 +202,32 @@ public abstract class AbstractHttp11Prot
* Regular expression that defines the User agents which should be
* restricted to HTTP/1.0 support.
*/
- private String restrictedUserAgents = null;
- public String getRestrictedUserAgents() { return restrictedUserAgents; }
- public void setRestrictedUserAgents(String valueS) {
- restrictedUserAgents = valueS;
+ private Pattern restrictedUserAgents = null;
+ public String getRestrictedUserAgents() {
+ if (restrictedUserAgents == null) {
+ return null;
+ } else {
+ return restrictedUserAgents.toString();
+ }
+ }
+ protected Pattern getRestrictedUserAgentsPattern() {
+ return restrictedUserAgents;
+ }
+ /**
+ * Set restricted user agent list (which will downgrade the connector
+ * to HTTP/1.0 mode). Regular expression as supported by {@link Pattern}.
+ *
+ * @param restrictedUserAgents The regular expression as supported by
+ * {@link Pattern} for the user agents e.g.
+ * "gorilla|desesplorer|tigrus"
+ */
+ public void setRestrictedUserAgents(String restrictedUserAgents) {
+ if (restrictedUserAgents == null ||
+ restrictedUserAgents.length() == 0) {
+ this.restrictedUserAgents = null;
+ } else {
+ this.restrictedUserAgents = Pattern.compile(restrictedUserAgents);
+ }
}
@@ -671,7 +694,6 @@ public abstract class AbstractHttp11Prot
processor.setCompression(getCompression());
processor.setNoCompressionUserAgents(getNoCompressionUserAgents());
processor.setCompressableMimeTypes(getCompressableMimeTypes());
- processor.setRestrictedUserAgents(getRestrictedUserAgents());
processor.setMaxSavePostSize(getMaxSavePostSize());
processor.setServer(getServer());
processor.setServerRemoveAppProvidedValues(getServerRemoveAppProvidedValues());
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=1774171&r1=1774170&r2=1774171&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:04:27 2016
@@ -129,12 +129,6 @@ public class Http11Processor extends Abs
/**
- * Regular expression that defines the restricted user agents.
- */
- protected Pattern restrictedUserAgents = null;
-
-
- /**
* Allowed compression level.
*/
protected int compressionLevel = 0;
@@ -340,24 +334,6 @@ public class Http11Processor extends Abs
/**
- * Set restricted user agent list (which will downgrade the connector
- * to HTTP/1.0 mode). Regular expression as supported by {@link Pattern}.
- *
- * @param restrictedUserAgents The regular expression as supported by
- * {@link Pattern} for the user agents e.g.
- * "gorilla|desesplorer|tigrus"
- */
- public void setRestrictedUserAgents(String restrictedUserAgents) {
- if (restrictedUserAgents == null ||
- restrictedUserAgents.length() == 0) {
- this.restrictedUserAgents = null;
- } else {
- this.restrictedUserAgents = Pattern.compile(restrictedUserAgents);
- }
- }
-
-
- /**
* Set the maximum size of a POST which will be buffered in SSL mode.
* When a POST is received where the security constraints require a client
* certificate, the POST body needs to be buffered while an SSL handshake
@@ -910,14 +886,14 @@ public class Http11Processor extends Abs
}
// Check user-agent header
+ Pattern restrictedUserAgents = protocol.getRestrictedUserAgentsPattern();
if (restrictedUserAgents != null && (http11 || keepAlive)) {
MessageBytes userAgentValueMB = headers.getValue("user-agent");
// Check in the restricted list, and adjust the http11
// and keepAlive flags accordingly
if(userAgentValueMB != null) {
String userAgentValue = userAgentValueMB.toString();
- if (restrictedUserAgents != null &&
- restrictedUserAgents.matcher(userAgentValue).matches()) {
+ if (restrictedUserAgents.matcher(userAgentValue).matches()) {
http11 = false;
keepAlive = false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org