diff --git a/lib/core/common.py b/lib/core/common.py index 1faef14ac..08e6cc46e 100755 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1007,6 +1007,14 @@ def sanitizeStr(value): return getUnicode(value).replace("\n", " ").replace("\r", "") +def getHeader(headers, key): + retVal = None + for _ in (headers or {}): + if _.upper() == key.upper(): + retVal = headers[_] + break + return retVal + def checkFile(filename): """ Checks for file existence and readability diff --git a/lib/request/connect.py b/lib/request/connect.py index 470c3dcc9..9951ed5d0 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -37,6 +37,7 @@ from lib.core.common import evaluateCode from lib.core.common import extractRegexResult from lib.core.common import findMultipartPostBoundary from lib.core.common import getCurrentThreadData +from lib.core.common import getHeader from lib.core.common import getHostHeader from lib.core.common import getRequestHeader from lib.core.common import getUnicode @@ -338,16 +339,16 @@ class Connect(object): if kb.proxyAuthHeader: headers[HTTP_HEADER.PROXY_AUTHORIZATION] = kb.proxyAuthHeader - if HTTP_HEADER.ACCEPT not in headers: + if not getHeader(headers, HTTP_HEADER.ACCEPT): headers[HTTP_HEADER.ACCEPT] = HTTP_ACCEPT_HEADER_VALUE - if HTTP_HEADER.HOST not in headers or not target: + if not getHeader(headers, HTTP_HEADER.HOST) or not target: headers[HTTP_HEADER.HOST] = getHostHeader(url) - if HTTP_HEADER.ACCEPT_ENCODING not in headers: + if not getHeader(headers, HTTP_HEADER.ACCEPT_ENCODING): headers[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if kb.pageCompress else "identity" - if post is not None and HTTP_HEADER.CONTENT_TYPE not in headers: + if post is not None and not getHeader(headers, HTTP_HEADER.CONTENT_TYPE): headers[HTTP_HEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE) if headers.get(HTTP_HEADER.CONTENT_TYPE) == POST_HINT_CONTENT_TYPES[POST_HINT.MULTIPART]: