Skip to content

Commit 05a496c

Browse files
committed
1 parent 9eb7a0a commit 05a496c

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,13 +1302,13 @@ def parseTargetUrl():
13021302
conf.url = getUnicode("%s://%s:%d%s" % (conf.scheme, ("[%s]" % conf.hostname) if conf.ipv6 else conf.hostname, conf.port, conf.path))
13031303
conf.url = conf.url.replace(URI_QUESTION_MARKER, '?')
13041304

1305-
if not conf.referer and intersect(REFERER_ALIASES, conf.testParameter, True):
1305+
if not conf.referer and (intersect(REFERER_ALIASES, conf.testParameter, True) or conf.level >= 3):
13061306
debugMsg = "setting the HTTP Referer header to the target URL"
13071307
logger.debug(debugMsg)
13081308
conf.httpHeaders = filter(lambda (key, value): key != HTTP_HEADER.REFERER, conf.httpHeaders)
13091309
conf.httpHeaders.append((HTTP_HEADER.REFERER, conf.url))
13101310

1311-
if not conf.host and intersect(HOST_ALIASES, conf.testParameter, True):
1311+
if not conf.host and (intersect(HOST_ALIASES, conf.testParameter, True) or conf.level >= 5):
13121312
debugMsg = "setting the HTTP Host header to the target URL"
13131313
logger.debug(debugMsg)
13141314
conf.httpHeaders = filter(lambda (key, value): key != HTTP_HEADER.HOST, conf.httpHeaders)

lib/core/option.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,17 @@ def _setHTTPReferer():
14001400

14011401
conf.httpHeaders.append((HTTP_HEADER.REFERER, conf.referer))
14021402

1403+
def _setHTTPHost():
1404+
"""
1405+
Set the HTTP Host
1406+
"""
1407+
1408+
if conf.host:
1409+
debugMsg = "setting the HTTP Host header"
1410+
logger.debug(debugMsg)
1411+
1412+
conf.httpHeaders.append((HTTP_HEADER.HOST, conf.host))
1413+
14031414
def _setHTTPCookies():
14041415
"""
14051416
Set the HTTP Cookie header
@@ -2381,6 +2392,7 @@ def init():
23812392
_setHTTPExtraHeaders()
23822393
_setHTTPCookies()
23832394
_setHTTPReferer()
2395+
_setHTTPHost()
23842396
_setHTTPUserAgent()
23852397
_setHTTPAuthentication()
23862398
_setHTTPProxy()

lib/request/connect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def getPage(**kwargs):
321321
requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
322322

323323
# Prepare HTTP headers
324-
headers = forgeHeaders({HTTP_HEADER.COOKIE: cookie, HTTP_HEADER.USER_AGENT: ua, HTTP_HEADER.REFERER: referer})
324+
headers = forgeHeaders({HTTP_HEADER.COOKIE: cookie, HTTP_HEADER.USER_AGENT: ua, HTTP_HEADER.REFERER: referer, HTTP_HEADER.HOST: host})
325325

326326
if kb.authHeader:
327327
headers[HTTP_HEADER.AUTHORIZATION] = kb.authHeader
@@ -332,11 +332,12 @@ def getPage(**kwargs):
332332
if HTTP_HEADER.ACCEPT not in headers:
333333
headers[HTTP_HEADER.ACCEPT] = HTTP_ACCEPT_HEADER_VALUE
334334

335+
if HTTP_HEADER.HOST not in headers:
336+
headers[HTTP_HEADER.HOST] = getHostHeader(url)
337+
335338
if HTTP_HEADER.ACCEPT_ENCODING not in headers:
336339
headers[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if kb.pageCompress else "identity"
337340

338-
headers[HTTP_HEADER.HOST] = host or getHostHeader(url)
339-
340341
if post is not None and HTTP_HEADER.CONTENT_TYPE not in headers:
341342
headers[HTTP_HEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE)
342343

0 commit comments

Comments
 (0)