]> granicus.if.org Git - apache/commitdiff
Merge r1610207 from trunk:
authorRainer Jung <rjung@apache.org>
Mon, 14 Jul 2014 06:05:22 +0000 (06:05 +0000)
committerRainer Jung <rjung@apache.org>
Mon, 14 Jul 2014 06:05:22 +0000 (06:05 +0000)
Forward local IP address as a custom request attribute
like we already do for the remote port.

Both were forgotten in the original AJP 13 spec
but are needed by the Servlet spec. Until now,
Tomcat simply returns for getLocalAddr() the same as
for getLocalName().

The next round of Tomcat releases will look for the
optional new request attribute.

See also Tomcat BZ 56661.

Submitted by: rjung
Reviewed by: trawick, ylavic

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1610340 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/proxy/ajp_header.c
modules/proxy/ajp_header.h

diff --git a/CHANGES b/CHANGES
index 4e14a253d530fd438d3d8431e20c4f0751914ac4..9c14956eed5ec6463fbc7b638e15ecab020d2ac7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.4.10
 
+  *) mod_proxy_ajp: Forward local IP address as a custom request attribute
+     like we already do for the remote port. [Rainer Jung]
+
   *) core: Include any error notes set by modules in the canned error
      response for 403 errors.  [Jeff Trawick]
 
diff --git a/STATUS b/STATUS
index 9086583177fd61d82d23840206ec63a462c82778..3ff689a1a4f79dbdd37a367b03dbc129ffc3f110 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -122,18 +122,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      ylavic: does not depend on r1572092 or r1572655 and al above,
              these proposals can be backported in any order.
 
-   * mod_proxy_ajp: Forward local IP address as a custom request attribute
-     like we already do for the remote port.
-     Both were forgotten in the original AJP 13 spec
-     but are needed by the Servlet spec. Until now,
-     Tomcat simply returns for getLocalAddr() the same as
-     for getLocalName().
-     The next round of Tomcat releases will look for the
-     optional new request attribute.
-     See also Tomcat BZ 56661.
-     trunk patch: http://svn.apache.org/r1610207
-     2.4.x patch: Trunk patch works plus CHANGES.
-     +1: rjung, trawick, ylavic
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 074f0a8d05bb8a9a1fb858cc2d76c549c882c415..8f9a2fcd3dea44349c85fc9ab5cc59f6d3334db8 100644 (file)
@@ -435,6 +435,26 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             return AJP_EOVERFLOW;
         }
     }
+    /* Forward the local ip address information, which was forgotten
+     * from the builtin data of the AJP 13 protocol.
+     * Since the servlet spec allows to retrieve it via getLocalAddr(),
+     * we provide the address to the Tomcat connector as a request
+     * attribute. Modern Tomcat versions know how to retrieve
+     * the local address from this attribute.
+     */
+    {
+        const char *key = SC_A_REQ_LOCAL_ADDR;
+        char *val = r->connection->local_ip;
+        if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
+            ajp_msg_append_string(msg, key)   ||
+            ajp_msg_append_string(msg, val)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02646)
+                    "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.
      */
index 22d890802c68b02d1f33fe6c264f43a50ec56b09..0f5fdaa81eab85061cc936057ef0c932c1632c2f 100644 (file)
  * to contain the forwarded remote port.
  */
 #define SC_A_REQ_REMOTE_PORT    ("AJP_REMOTE_PORT")
+/*
+ * The following request attribute is recognized by Tomcat
+ * to contain the forwarded local ip address.
+ */
+#define SC_A_REQ_LOCAL_ADDR     ("AJP_LOCAL_ADDR")
 
 /*
  * Request methods, coded as numbers instead of strings.