-
Notifications
You must be signed in to change notification settings - Fork 196
Convert headers to strings in HTTP20Adapter to fix #324 #335
Conversation
hyper/contrib.py
Outdated
@@ -132,7 +132,10 @@ def build_response(self, request, resp): | |||
response = Response() | |||
|
|||
response.status_code = resp.status | |||
response.headers = CaseInsensitiveDict(resp.headers.iter_raw()) | |||
response.headers = CaseInsensitiveDict(( | |||
map(lambda h: h.decode("utf-8"), h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little overbroad. To match urllib3 we only want to do this on Python 3: on Python 2 these should stay as bytes.
hyper/contrib.py
Outdated
from sys import version_info as pyver | ||
|
||
|
||
conditionalToStr=lambda s: s.decode("utf-8") if pyver > 2 else lambda s: s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely no need to use a lambda here, let alone two: just use this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks! ✨
hyper/contrib.py
Outdated
@@ -19,6 +19,7 @@ | |||
from hyper.common.connection import HTTPConnection | |||
from hyper.compat import urlparse, ssl | |||
from hyper.tls import init_context | |||
from hyper.util import to_native_string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is hyper.common.util
.
No description provided.