tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r757470 - in /tomcat/tc6.0.x/trunk: ./ java/org/apache/coyote/ajp/ java/org/apache/jk/common/ webapps/docs/
Date Mon, 23 Mar 2009 17:54:42 GMT
Author: rjung
Date: Mon Mar 23 17:54:41 2009
New Revision: 757470

URL: http://svn.apache.org/viewvc?rev=757470&view=rev
Log:
Set remote port for AJP connectors from the optional request
attribute AJP_REMOTE_PORT.

Backport of r756926 and r757223.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java
    tomcat/tc6.0.x/trunk/java/org/apache/jk/common/AjpConstants.java
    tomcat/tc6.0.x/trunk/java/org/apache/jk/common/HandlerRequest.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Mar 23 17:54:41 2009
@@ -118,21 +118,3 @@
   Backport of http://svn.apache.org/viewvc?rev=755302&view=rev
   +1: rjung, fhanik, pero
   -1:
-
-* Allow AJP connectors to provide correct getRemotePort().
-  The remote port is not part of the AJP13 protocol.
-  Since the protocol is not extensible enough for standard
-  attributes, we use generic attributes mechanism to forward
-  the remote port.
-  Backport of http://svn.apache.org/viewvc?rev=756926&view=rev
-  and http://svn.apache.org/viewvc?rev=757223&view=rev
-  +1: rjung, pero, mturk, billbarker
-  -1:
-  mturk: Perhaps we should consider prefixing all those private
-  variables with AJP_ so that is clear this is AJP protocol
-  extension environment variable.
-  pero: But REMOTE_PORT is a existing apache httpd env var! +1 for prefixing.
-        What we can do at mod_jk/IIS?
-  rjung: I changed the name and we will *only* use the forwarded data
-  for setting the port and not set it as a request attribute.
-  IIS: will be handled similarly.

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Mon Mar 23 17:54:41
2009
@@ -706,7 +706,21 @@
                 String n = tmpMB.toString();
                 requestHeaderMessage.getBytes(tmpMB);
                 String v = tmpMB.toString();
-                request.setAttribute(n, v);
+                /*
+                 * AJP13 misses to forward the remotePort.
+                 * 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(Constants.SC_A_REQ_REMOTE_PORT)) {
+                    try {
+                        request.setRemotePort(Integer.parseInt(v));
+                    } catch (NumberFormatException nfe) {
+                    }
+                } else {
+                    request.setAttribute(n, v );
+                }
                 break;
 
             case Constants.SC_A_CONTEXT :

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Mon Mar 23 17:54:41
2009
@@ -712,7 +712,21 @@
                 String n = tmpMB.toString();
                 requestHeaderMessage.getBytes(tmpMB);
                 String v = tmpMB.toString();
-                request.setAttribute(n, v);
+                /*
+                 * AJP13 misses to forward the remotePort.
+                 * 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(Constants.SC_A_REQ_REMOTE_PORT)) {
+                    try {
+                        request.setRemotePort(Integer.parseInt(v));
+                    } catch (NumberFormatException nfe) {
+                    }
+                } else {
+                    request.setAttribute(n, v );
+                }
                 break;
 
             case Constants.SC_A_CONTEXT :

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/Constants.java Mon Mar 23 17:54:41 2009
@@ -88,6 +88,11 @@
     // 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;
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jk/common/AjpConstants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jk/common/AjpConstants.java?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jk/common/AjpConstants.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jk/common/AjpConstants.java Mon Mar 23 17:54:41 2009
@@ -97,6 +97,11 @@
     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;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jk/common/HandlerRequest.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jk/common/HandlerRequest.java?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jk/common/HandlerRequest.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jk/common/HandlerRequest.java Mon Mar 23 17:54:41
2009
@@ -455,9 +455,23 @@
                 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.
+                 * 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(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);
+                }
             }
 
 

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=757470&r1=757469&r2=757470&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Mar 23 17:54:41 2009
@@ -33,6 +33,14 @@
 
 <body>
 <section name="Tomcat 6.0.20 (remm)">
+  <subsection name="Coyote">
+    <changelog>
+      <update>
+        Set remote port for AJP connectors from the optional request
+        attribute AJP_REMOTE_PORT. (rjung)
+      </update>
+    </changelog>
+  </subsection>
   <subsection name="Webapps">
     <changelog>
       <fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message