summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python3/httplib2/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index 43f7419..b7b00b1 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -192,8 +192,13 @@ def safename(filename):
NORMALIZE_SPACE = re.compile(r'(?:\r\n)?[ \t]+')
def _normalize_headers(headers):
- return dict([ (key.lower(), NORMALIZE_SPACE.sub(value, ' ').strip()) for (key, value) in headers.items()])
+ return dict([ (_convert_byte_str(key).lower(), NORMALIZE_SPACE.sub(_convert_byte_str(value), ' ').strip()) for (key, value) in headers.items()])
+def _convert_byte_str(s):
+ if not isinstance(s, str):
+ return str(s, 'utf-8')
+ return s
+
def _parse_cache_control(headers):
retval = {}
if 'cache-control' in headers: