Fix uri for change in case in response
In python3, response fields are title cased whereas in python2 they were
not. We return these fields to the module's caller so we need to
normalize all of them to be lower case.
This reverts the lowercase check from 454f741ef5
as that one was only targetted as a single field.
This commit is contained in:
parent
dfc2a29bdb
commit
38b3c43c68
1 changed files with 5 additions and 9 deletions
|
@ -437,9 +437,11 @@ def main():
|
|||
|
||||
# Transmogrify the headers, replacing '-' with '_', since variables dont
|
||||
# work with dashes.
|
||||
# In python3, the headers are title cased. Lowercase them to be
|
||||
# compatible with the python2 behaviour.
|
||||
uresp = {}
|
||||
for key, value in six.iteritems(resp):
|
||||
ukey = key.replace("-", "_")
|
||||
ukey = key.replace("-", "_").lower()
|
||||
uresp[ukey] = value
|
||||
|
||||
try:
|
||||
|
@ -449,14 +451,8 @@ def main():
|
|||
|
||||
# Default content_encoding to try
|
||||
content_encoding = 'utf-8'
|
||||
content_type_key = None
|
||||
for key in uresp:
|
||||
# Py2: content_type; Py3: Content_type
|
||||
if 'content_type' == key.lower():
|
||||
content_type_key = key
|
||||
break
|
||||
if content_type_key is not None:
|
||||
content_type, params = cgi.parse_header(uresp[content_type_key])
|
||||
if 'content_type' in uresp:
|
||||
content_type, params = cgi.parse_header(uresp['content_type'])
|
||||
if 'charset' in params:
|
||||
content_encoding = params['charset']
|
||||
u_content = to_text(content, encoding=content_encoding)
|
||||
|
|
Loading…
Reference in a new issue