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 2014/07/13 16:20:05 UTC

svn commit: r1610207 - in /httpd/httpd/trunk: docs/log-message-tags/next-number modules/proxy/ajp_header.c modules/proxy/ajp_header.h

Author: rjung
Date: Sun Jul 13 14:20:04 2014
New Revision: 1610207

URL: http://svn.apache.org/r1610207
Log:
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.

Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/modules/proxy/ajp_header.c
    httpd/httpd/trunk/modules/proxy/ajp_header.h

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1610207&r1=1610206&r2=1610207&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Sun Jul 13 14:20:04 2014
@@ -1 +1 @@
-2646
+2647

Modified: httpd/httpd/trunk/modules/proxy/ajp_header.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_header.c?rev=1610207&r1=1610206&r2=1610207&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_header.c (original)
+++ httpd/httpd/trunk/modules/proxy/ajp_header.c Sun Jul 13 14:20:04 2014
@@ -435,6 +435,26 @@ static apr_status_t ajp_marshal_into_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.
      */

Modified: httpd/httpd/trunk/modules/proxy/ajp_header.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_header.h?rev=1610207&r1=1610206&r2=1610207&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_header.h (original)
+++ httpd/httpd/trunk/modules/proxy/ajp_header.h Sun Jul 13 14:20:04 2014
@@ -51,6 +51,11 @@
  * 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.