]> granicus.if.org Git - apache/commitdiff
Fix IPv6 literal addresses passed to a proxied backend.
authorNick Kew <niq@apache.org>
Mon, 25 May 2009 23:19:16 +0000 (23:19 +0000)
committerNick Kew <niq@apache.org>
Mon, 25 May 2009 23:19:16 +0000 (23:19 +0000)
PR 47177
Patch by Carlos Garcia Braschi

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@778531 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/mod_proxy_http.c

diff --git a/CHANGES b/CHANGES
index c88cfbec6d47014d01443f75b8411a1553a503cf..657b0ad0e62aeea879cba9d404bcb774960ef5c2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@ Changes with Apache 2.3.3
      mod_proxy_ajp: Avoid delivering content from a previous request which
      failed to send a request body. PR 46949 [Ruediger Pluem]
 
+  *) mod_proxy_http: fix Host: header for literal IPv6 addresses.
+     PR 47177 [Carlos Garcia Braschi <cgbraschi gmail.com>]
+
   *) mod_cache: Add CacheIgnoreURLSessionIdentifiers directive to ignore
      defined session identifiers encoded in the URL when caching.
      [Ruediger Pluem]
index 3f709c4fab1250895355887ae6ac5cfa75fce02b..1e80985a790e323b9766ad259bd7470589c3fef7 100644 (file)
@@ -713,11 +713,20 @@ int ap_proxy_http_request(apr_pool_t *p, request_rec *r,
     e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
     APR_BRIGADE_INSERT_TAIL(header_brigade, e);
     if (conf->preserve_host == 0) {
-        if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
-            buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str,
-                              CRLF, NULL);
+        if (ap_strchr_c(uri->hostname, ':')) { /* if literal IPv6 address */
+            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
+                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]:", 
+                                  uri->port_str, CRLF, NULL);
+            } else {
+                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]", CRLF, NULL);
+            }
         } else {
-            buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
+            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
+                buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", 
+                                  uri->port_str, CRLF, NULL);
+            } else {
+                buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
+            }
         }
     }
     else {