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:
Toshio Kuratomi 2016-10-24 07:01:00 -07:00 committed by Matt Clay
parent dfc2a29bdb
commit 38b3c43c68

View file

@ -437,9 +437,11 @@ def main():
# Transmogrify the headers, replacing '-' with '_', since variables dont # Transmogrify the headers, replacing '-' with '_', since variables dont
# work with dashes. # work with dashes.
# In python3, the headers are title cased. Lowercase them to be
# compatible with the python2 behaviour.
uresp = {} uresp = {}
for key, value in six.iteritems(resp): for key, value in six.iteritems(resp):
ukey = key.replace("-", "_") ukey = key.replace("-", "_").lower()
uresp[ukey] = value uresp[ukey] = value
try: try:
@ -449,14 +451,8 @@ def main():
# Default content_encoding to try # Default content_encoding to try
content_encoding = 'utf-8' content_encoding = 'utf-8'
content_type_key = None if 'content_type' in uresp:
for key in uresp: content_type, params = cgi.parse_header(uresp['content_type'])
# 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 'charset' in params: if 'charset' in params:
content_encoding = params['charset'] content_encoding = params['charset']
u_content = to_text(content, encoding=content_encoding) u_content = to_text(content, encoding=content_encoding)