------------------------------------------------------------
revno: 13240
revision-id: squid3@treenet.co.nz-20160509131121-4saxl1wj54n20lgf
parent: squid3@treenet.co.nz-20160508124218-6vhq4icj0fwu5aof
fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4501
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.4
timestamp: Tue 2016-05-10 01:11:21 +1200
message:
Bug 4501: HTTP/1.1: normalize Host header
------------------------------------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: squid3@treenet.co.nz-20160509131121-4saxl1wj54n20lgf
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# testament_sha1: 017af15dae3e77239e9b2449dc2f2711707447d9
# timestamp: 2016-05-09 13:13:52 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.4
# base_revision_id: squid3@treenet.co.nz-20160508124218-\
# 6vhq4icj0fwu5aof
#
# Begin patch
=== modified file 'src/client_side.cc'
--- src/client_side.cc 2015-08-28 13:23:34 +0000
+++ src/client_side.cc 2016-05-09 13:11:21 +0000
@@ -2740,6 +2740,23 @@
goto finish;
}
+ // when absolute-URI is provided Host header should be ignored. However
+ // some code still uses Host directly so normalize it.
+ // For now preserve the case where Host is completely absent.
+ if (request->header.has(HDR_HOST)) {
+ const char *host = request->header.getStr(HDR_HOST);
+ MemBuf authority;
+ authority.init();
+ if (request->port != urlDefaultPort(request->protocol))
+ authority.Printf("%s:%d", request->GetHost(), request->port);
+ else
+ authority.Printf("%s", request->GetHost());
+ debugs(33, 5, "URL domain " << authority.buf << " overrides header Host: " << host);
+ // URL authority overrides Host header
+ request->header.delById(HDR_HOST);
+ request->header.putStr(HDR_HOST, authority.buf);
+ }
+
request->clientConnectionManager = conn;
request->flags.accelerated = http->flags.accel;