]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: Port forward the solution for bug #699 (rewrite host header in place).
authorrobertc <>
Wed, 23 Jul 2003 17:39:44 +0000 (17:39 +0000)
committerrobertc <>
Wed, 23 Jul 2003 17:39:44 +0000 (17:39 +0000)
Keywords:

This fixes some causes for 'Zero sized reply' when squid connects via a firewall.

src/http.cc

index e7ee003d96d3429332795decf3657e1d5b6cea23..23620f707a574de83ac35fd8b6aa1ff037f5b078 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.422 2003/07/23 10:41:20 robertc Exp $
+ * $Id: http.cc,v 1.423 2003/07/23 11:39:44 robertc Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1376,22 +1376,31 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, St
 
     case HDR_HOST:
         /*
-         * Normally Squid does not copy the Host: header from
-         * a client request into the forwarded request headers.
-         * However, there is one case when we do: If the URL
+         * Normally Squid rewrites the Host: header.
+         * However, there is one case when we don't: If the URL
          * went through our redirector and the admin configured
          * 'redir_rewrites_host' to be off.
          */
 
-        if (request->flags.redirected)
-            if (!Config.onoff.redir_rewrites_host)
-                httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e));
+        if (request->flags.redirected && !Config.onoff.redir_rewrites_host)
+            httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e));
+        else {
+            /* use port# only if not default */
+
+            if (orig_request->port == urlDefaultPort(orig_request->protocol)) {
+                httpHeaderPutStr(hdr_out, HDR_HOST, orig_request->host);
+            } else {
+                httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d",
+                                  orig_request->host, (int) orig_request->port);
+            }
+        }
 
         break;
 
     case HDR_IF_MODIFIED_SINCE:
         /* append unless we added our own;
          * note: at most one client's ims header can pass through */
+
         if (!httpHeaderHas(hdr_out, HDR_IF_MODIFIED_SINCE))
             httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e));