- Use a more private attribute name and
define it in the Constants class.
- Do not set the attribute on the request,
only use it for the remote port.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@757223
13f79535-47bb-0310-9956-
ffa450edef68
String n = tmpMB.toString();
requestHeaderMessage.getBytes(tmpMB);
String v = tmpMB.toString();
- request.setAttribute(n, v);
/*
* AJP13 misses to forward the remotePort.
- * Apache automatically sets REMOTE_PORT to the remote port.
- * Allow the user to set "JkEnvVar REMOTE_PORT" and
- * let us accept the forwarded port as the remote port.
+ * Allow the AJP connector to add this info via
+ * a private request attribute.
+ * We will accept the forwarded data as the remote port,
+ * and remove it from the public list of request attributes.
*/
- if(n.equals("REMOTE_PORT")) {
+ if(n.equals(Constants.SC_A_REQ_REMOTE_PORT)) {
try {
request.setRemotePort(Integer.parseInt(v));
} catch (NumberFormatException nfe) {
}
+ } else {
+ request.setAttribute(n, v);
}
break;
String n = tmpMB.toString();
requestHeaderMessage.getBytes(tmpMB);
String v = tmpMB.toString();
- request.setAttribute(n, v);
/*
* AJP13 misses to forward the remotePort.
- * Apache automatically sets REMOTE_PORT to the remote port.
- * Allow the user to set "JkEnvVar REMOTE_PORT" and
- * let us accept the forwarded port as the remote port.
+ * Allow the AJP connector to add this info via
+ * a private request attribute.
+ * We will accept the forwarded data as the remote port,
+ * and remove it from the public list of request attributes.
*/
- if(n.equals("REMOTE_PORT")) {
+ if(n.equals(Constants.SC_A_REQ_REMOTE_PORT)) {
try {
request.setRemotePort(Integer.parseInt(v));
} catch (NumberFormatException nfe) {
}
+ } else {
+ request.setAttribute(n, v );
}
break;
// Used for attributes which are not in the list above
public static final byte SC_A_REQ_ATTRIBUTE = 10;
+ /**
+ * AJP private request attributes
+ */
+ public static final String SC_A_REQ_REMOTE_PORT = "AJP_REMOTE_PORT";
+
// Terminates list of attributes
public static final byte SC_A_ARE_DONE = (byte)0xFF;
public static final byte SC_A_REQ_ATTRIBUTE = 10;
/**
+ * AJP private request attributes
+ */
+ public static final String SC_A_REQ_REMOTE_PORT = "AJP_REMOTE_PORT";
+
+ /**
* Terminates list of attributes
*/
public static final byte SC_A_ARE_DONE = (byte)0xFF;
String n=tmpMB.toString();
msg.getBytes( tmpMB );
String v=tmpMB.toString();
- req.setAttribute(n, v );
- if(log.isTraceEnabled())
- log.trace("jk Attribute set " + n + "=" + v);
/*
* AJP13 misses to forward the remotePort.
- * Apache automatically sets REMOTE_PORT to the remote port.
- * Allow the user to set "JkEnvVar REMOTE_PORT" and
- * let us accept the forwarded port as the remote port.
+ * Allow the AJP connector to add this info via
+ * a private request attribute.
+ * We will accept the forwarded data as the remote port,
+ * and remove it from the public list of request attributes.
*/
- if(n.equals("REMOTE_PORT")) {
+ if(n.equals(AjpConstants.SC_A_REQ_REMOTE_PORT)) {
try {
req.setRemotePort(Integer.parseInt(v));
} catch (NumberFormatException nfe) {
}
+ } else {
+ req.setAttribute(n, v );
+ if(log.isTraceEnabled())
+ log.trace("jk Attribute set " + n + "=" + v);
}
}