You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mi...@apache.org on 2019/07/09 13:55:27 UTC
[tomcat] 02/02: Better attribute name
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch mark-forwarded-request/8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 644af221e5cb8e6a17327c9a4319a69a2d1dc305
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Jul 9 15:53:36 2019 +0200
Better attribute name
---
java/org/apache/catalina/Globals.java | 11 +++++------
java/org/apache/catalina/filters/RemoteIpFilter.java | 2 +-
java/org/apache/catalina/valves/RemoteIpValve.java | 4 ++--
java/org/apache/coyote/Constants.java | 9 ++++-----
test/org/apache/catalina/filters/TestRemoteIpFilter.java | 4 ++--
test/org/apache/catalina/valves/TestRemoteIpValve.java | 4 ++--
6 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/java/org/apache/catalina/Globals.java b/java/org/apache/catalina/Globals.java
index edf91a0..7ce8209 100644
--- a/java/org/apache/catalina/Globals.java
+++ b/java/org/apache/catalina/Globals.java
@@ -200,13 +200,12 @@ public final class Globals {
/**
- * The request attribute set by the RemoteIpFilter, RemoteIpValve (and may
- * be set by other similar components) that identifies this request has been
- * forwarded via one or more proxies. The value should be {@code java.lang.Boolean}.
- * Absence shall be treated as {@code false}.
+ * The request attribute that is set to the value of {@code Boolean.TRUE}
+ * by the RemoteIpFilter, RemoteIpValve (and other similar components) that identifies
+ * a request which been forwarded via one or more proxies.
*/
- public static final String FORWARDED_REQUEST_ATTRIBUTE =
- org.apache.coyote.Constants.FORWARDED_REQUEST_ATTRIBUTE;
+ public static final String REQUEST_FORWARDED_ATTRIBUTE =
+ org.apache.coyote.Constants.REQUEST_FORWARDED_ATTRIBUTE;
public static final String ASYNC_SUPPORTED_ATTR =
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java
index f416f60..423b561 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -85,7 +85,7 @@ import org.apache.juli.logging.LogFactory;
* <code>protocolHeaderHttpsValue</code> configuration parameter (default <code>https</code>) then <code>request.isSecure = true</code>,
* <code>request.scheme = https</code> and <code>request.serverPort = 443</code>. Note that 443 can be overwritten with the
* <code>$httpsServerPort</code> configuration parameter.</li>
- * <li>Mark the request with the attribute {@link Globals#FORWARDED_REQUEST_ATTRIBUTE} and value {@code Boolean.TRUE} to indicate
+ * <li>Mark the request with the attribute {@link Globals#REQUEST_FORWARDED_ATTRIBUTE} and value {@code Boolean.TRUE} to indicate
* that this request has been forwarded by one or more proxies.</li>
* </ul>
* <table border="1">
diff --git a/java/org/apache/catalina/valves/RemoteIpValve.java b/java/org/apache/catalina/valves/RemoteIpValve.java
index 9e78c0f..cd08cc7 100644
--- a/java/org/apache/catalina/valves/RemoteIpValve.java
+++ b/java/org/apache/catalina/valves/RemoteIpValve.java
@@ -64,7 +64,7 @@ import org.apache.tomcat.util.http.MimeHeaders;
* <code>protocolHeaderHttpsValue</code> configuration parameter (default <code>https</code>) then <code>request.isSecure = true</code>,
* <code>request.scheme = https</code> and <code>request.serverPort = 443</code>. Note that 443 can be overwritten with the
* <code>$httpsServerPort</code> configuration parameter.</li>
- * <li>Mark the request with the attribute {@link Globals#FORWARDED_REQUEST_ATTRIBUTE} and value {@code Boolean.TRUE} to indicate
+ * <li>Mark the request with the attribute {@link Globals#REQUEST_FORWARDED_ATTRIBUTE} and value {@code Boolean.TRUE} to indicate
* that this request has been forwarded by one or more proxies.</li>
* </ul>
* <table border="1">
@@ -653,7 +653,7 @@ public class RemoteIpValve extends ValveBase {
}
}
- request.setAttribute(Globals.FORWARDED_REQUEST_ATTRIBUTE, Boolean.TRUE);
+ request.setAttribute(Globals.REQUEST_FORWARDED_ATTRIBUTE, Boolean.TRUE);
if (log.isDebugEnabled()) {
log.debug("Incoming request " + request.getRequestURI() + " with originalRemoteAddr '" + originalRemoteAddr
diff --git a/java/org/apache/coyote/Constants.java b/java/org/apache/coyote/Constants.java
index 58fa1e5..898068a 100644
--- a/java/org/apache/coyote/Constants.java
+++ b/java/org/apache/coyote/Constants.java
@@ -113,10 +113,9 @@ public final class Constants {
public static final String REMOTE_ADDR_ATTRIBUTE = "org.apache.tomcat.remoteAddr";
/**
- * The request attribute set by the RemoteIpFilter, RemoteIpValve (and may
- * be set by other similar components) that identifies this request has been
- * forwarded via one or more proxies. The value should be {@code java.lang.Boolean}.
- * Absence shall be treated as {@code false}.
+ * The request attribute that is set to the value of {@code Boolean.TRUE}
+ * by the RemoteIpFilter, RemoteIpValve (and other similar components) that identifies
+ * a request which been forwarded via one or more proxies.
*/
- public static final String FORWARDED_REQUEST_ATTRIBUTE = "org.apache.tomcat.forwardedRequest";
+ public static final String REQUEST_FORWARDED_ATTRIBUTE = "org.apache.tomcat.request.forwarded";
}
diff --git a/test/org/apache/catalina/filters/TestRemoteIpFilter.java b/test/org/apache/catalina/filters/TestRemoteIpFilter.java
index e8323e9..3fb6580 100644
--- a/test/org/apache/catalina/filters/TestRemoteIpFilter.java
+++ b/test/org/apache/catalina/filters/TestRemoteIpFilter.java
@@ -643,9 +643,9 @@ public class TestRemoteIpFilter extends TomcatBaseTest {
HttpServletRequest actualRequest = testRemoteIpFilter(filterDef, request).getRequest();
// VERIFY
- Assert.assertEquals("org.apache.tomcat.forwardedRequest",
+ Assert.assertEquals("org.apache.tomcat.request.forwarded",
Boolean.TRUE,
- actualRequest.getAttribute(Globals.FORWARDED_REQUEST_ATTRIBUTE));
+ actualRequest.getAttribute(Globals.REQUEST_FORWARDED_ATTRIBUTE));
}
/*
diff --git a/test/org/apache/catalina/valves/TestRemoteIpValve.java b/test/org/apache/catalina/valves/TestRemoteIpValve.java
index 21d79d3..cb26382 100644
--- a/test/org/apache/catalina/valves/TestRemoteIpValve.java
+++ b/test/org/apache/catalina/valves/TestRemoteIpValve.java
@@ -1005,9 +1005,9 @@ public class TestRemoteIpValve {
remoteIpValve.invoke(request, null);
// VERIFY
- Assert.assertEquals("org.apache.tomcat.forwardedRequest",
+ Assert.assertEquals("org.apache.tomcat.request.forwarded",
Boolean.TRUE,
- request.getAttribute(Globals.FORWARDED_REQUEST_ATTRIBUTE));
+ request.getAttribute(Globals.REQUEST_FORWARDED_ATTRIBUTE));
}
private void assertArrayEquals(String[] expected, String[] actual) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org