From: Jim Jagielski Date: Fri, 17 Apr 2009 13:40:08 +0000 (+0000) Subject: Merge r761329 from trunk: X-Git-Tag: 2.2.12~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbc16c8d6d1cf46df80682383729c49ec71160cb;p=thirdparty%2Fapache%2Fhttpd.git Merge r761329 from trunk: 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 Submitted by: rjung Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@765998 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 5838153e17d..1554a898f38 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.12 + *) mod_proxy_ajp: Forward remote port information by default. + [Rainer Jung] + *) mod_disk_cache/mod_mem_cache: Fix handling of CacheIgnoreHeaders directive to correctly remove headers before storing them. [Lars Eilebrecht] diff --git a/STATUS b/STATUS index 6a95b0091cb..906244eb7ff 100644 --- a/STATUS +++ b/STATUS @@ -95,20 +95,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_proxy_ajp: 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. - For the AJP/Tomcat part 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 - Patch in trunk: - http://svn.apache.org/viewvc?rev=761329&view=rev - +1: rjung, rpluem, wrowe, jim - * mod_mime_magic: For compressed content the module sets the content encoding header and also tries to determine the uncompressed content type by using an external gzip. diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c index 9130de9a78a..90a5a074d94 100644 --- a/modules/proxy/ajp_header.c +++ b/modules/proxy/ajp_header.c @@ -403,6 +403,26 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg, } } } + /* 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. */ diff --git a/modules/proxy/ajp_header.h b/modules/proxy/ajp_header.h index bb6adae3277..35379feef9e 100644 --- a/modules/proxy/ajp_header.h +++ b/modules/proxy/ajp_header.h @@ -43,6 +43,14 @@ #define SC_A_SECRET (unsigned char)12 #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,