From: robertc <> Date: Wed, 23 Jul 2003 17:39:44 +0000 (+0000) Subject: Summary: Port forward the solution for bug #699 (rewrite host header in place). X-Git-Tag: SQUID_3_0_PRE2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b883b594bdfdef49b22874738501f742e8ac2d31;p=thirdparty%2Fsquid.git Summary: Port forward the solution for bug #699 (rewrite host header in place). Keywords: This fixes some causes for 'Zero sized reply' when squid connects via a firewall. --- diff --git a/src/http.cc b/src/http.cc index e7ee003d96..23620f707a 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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));