Fix for an Issue #85

This commit is contained in:
Miroslav Stampar 2014-01-02 12:09:58 +01:00
parent 4de83daf03
commit 5437f8bf36

View File

@ -15,6 +15,7 @@ import zlib
from lib.core.common import extractErrorMessage from lib.core.common import extractErrorMessage
from lib.core.common import extractRegexResult from lib.core.common import extractRegexResult
from lib.core.common import getPublicTypeMembers
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import resetCookieJar from lib.core.common import resetCookieJar
@ -53,7 +54,27 @@ def forgeHeaders(items=None):
headers = dict(conf.httpHeaders) headers = dict(conf.httpHeaders)
headers.update(items or {}) headers.update(items or {})
headers = dict(("-".join(_.capitalize() for _ in key.split('-')), value) for (key, value) in headers.items()) class _str(str):
def capitalize(self):
return _str(self)
def title(self):
return _str(self)
_ = headers
headers = {}
for key, value in _.items():
success = False
if key.upper() not in (_.upper() for _ in getPublicTypeMembers(HTTP_HEADER, True)):
try:
headers[_str(key)] = value # dirty hack for http://bugs.python.org/issue12455
except UnicodeEncodeError: # don't do the hack on non-ASCII header names (they have to be properly encoded later on)
pass
else:
success = True
if not success:
key = '-'.join(_.capitalize() for _ in key.split('-'))
headers[key] = value
if conf.cj: if conf.cj:
if HTTP_HEADER.COOKIE in headers: if HTTP_HEADER.COOKIE in headers: