You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rj...@apache.org on 2009/04/02 17:49:29 UTC

svn commit: r761329 - in /httpd/httpd/trunk: CHANGES modules/proxy/ajp_header.c modules/proxy/ajp_header.h

Author: rjung
Date: Thu Apr  2 15:49:29 2009
New Revision: 761329

URL: http://svn.apache.org/viewvc?rev=761329&view=rev
Log:
The remote port information was forgotten from the builtin
data of the AJP 13 protocol.  Since the servlet spec allows
to retrieve it via getRemotePort(), we provide the port to
the Tomcat connector as an additional request attribute.
Modern/future Tomcat versions know how to retrieve
the remote port from the attribute AJP_REMOTE_PORT.

See:
https://issues.apache.org/bugzilla/show_bug.cgi?id=41263
http://svn.eu.apache.org/viewvc?view=rev&revision=756926
http://svn.eu.apache.org/viewvc?view=rev&revision=757223

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/proxy/ajp_header.c
    httpd/httpd/trunk/modules/proxy/ajp_header.h

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=761329&r1=761328&r2=761329&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Apr  2 15:49:29 2009
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.3
 
+  *) mod_proxy_ajp: Forward remote port information by default.
+     [Rainer Jung]
+
   *) Allow MPMs to be loaded dynamically, as with most other modules.  This
      required changes to the MPM interfaces.  Removed: mpm.h, mpm_default.h
      (as an installed header), APACHE_MPM_DIR, MPM_NAME, ap_threads_per_child, 

Modified: httpd/httpd/trunk/modules/proxy/ajp_header.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_header.c?rev=761329&r1=761328&r2=761329&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_header.c (original)
+++ httpd/httpd/trunk/modules/proxy/ajp_header.c Thu Apr  2 15:49:29 2009
@@ -403,6 +403,26 @@
             }
         }
     }
+    /* Forward the remote port information, which was forgotten
+     * from the builtin data of the AJP 13 protocol.
+     * Since the servlet spec allows to retrieve it via getRemotePort(),
+     * we provide the port to the Tomcat connector as a request
+     * attribute. Modern Tomcat versions know how to retrieve
+     * the remote port from this attribute.
+     */
+    {
+        const char *key = SC_A_REQ_REMOTE_PORT;
+        char *val = apr_itoa(r->pool, r->connection->remote_addr->port);
+        if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
+            ajp_msg_append_string(msg, key)   ||
+            ajp_msg_append_string(msg, val)) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                    "ajp_marshal_into_msgb: "
+                    "Error appending attribute %s=%s",
+                    key, val);
+            return AJP_EOVERFLOW;
+        }
+    }
     /* Use the environment vars prefixed with AJP_
      * and pass it to the header striping that prefix.
      */

Modified: httpd/httpd/trunk/modules/proxy/ajp_header.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_header.h?rev=761329&r1=761328&r2=761329&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_header.h (original)
+++ httpd/httpd/trunk/modules/proxy/ajp_header.h Thu Apr  2 15:49:29 2009
@@ -44,6 +44,14 @@
 #define SC_A_ARE_DONE           (unsigned char)0xFF
 
 /*
+ * AJP private request attributes
+ *
+ * The following request attribute is recognized by Tomcat
+ * to contain the forwarded remote port.
+ */
+#define SC_A_REQ_REMOTE_PORT    ("AJP_REMOTE_PORT")
+
+/*
  * Request methods, coded as numbers instead of strings.
  * The list of methods was taken from Section 5.1.1 of RFC 2616,
  * RFC 2518, the ACL IETF draft, and the DeltaV IESG Proposed Standard.