Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Convert headers to strings in HTTP20Adapter to fix #324 #335

Merged
merged 8 commits into from
Jul 5, 2017

Conversation

KOLANICH
Copy link
Contributor

@KOLANICH KOLANICH commented Jul 4, 2017

No description provided.

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)
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

@Lukasa Lukasa left a 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
Copy link
Member

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.

@Lukasa Lukasa merged commit 8345852 into python-hyper:development Jul 5, 2017
@KOLANICH KOLANICH deleted the patch-1 branch July 5, 2017 08:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants