diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-05-29 11:14:46 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-05-29 11:14:46 +1200 |
commit | ed415877d48251774012bd6aad4be91e9d558b79 (patch) | |
tree | e12a399c6df498f24aa5eeb9652dfaa90ab98dae /netlib/http/message.py | |
parent | 00426534982ab7fba5617ad6422c13483a8e6521 (diff) | |
parent | 7971dce2231bc32c25b962d425d8ad935568a699 (diff) | |
download | mitmproxy-ed415877d48251774012bd6aad4be91e9d558b79.tar.gz mitmproxy-ed415877d48251774012bd6aad4be91e9d558b79.tar.bz2 mitmproxy-ed415877d48251774012bd6aad4be91e9d558b79.zip |
Merge branch 'master' into solidcore
Diffstat (limited to 'netlib/http/message.py')
-rw-r--r-- | netlib/http/message.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/netlib/http/message.py b/netlib/http/message.py index 028f43a1..13d401a7 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -4,17 +4,23 @@ import warnings import six -from ..multidict import MultiDict from .headers import Headers from .. import encoding, utils +from ..utils import always_bytes if six.PY2: # pragma: no cover - _native = lambda x: x - _always_bytes = lambda x: x + def _native(x): + return x + + def _always_bytes(x): + return x else: - # While the HTTP head _should_ be ASCII, it's not uncommon for certain headers to be utf-8 encoded. - _native = lambda x: x.decode("utf-8", "surrogateescape") - _always_bytes = lambda x: utils.always_bytes(x, "utf-8", "surrogateescape") + # While headers _should_ be ASCII, it's not uncommon for certain headers to be utf-8 encoded. + def _native(x): + return x.decode("utf-8", "surrogateescape") + + def _always_bytes(x): + return always_bytes(x, "utf-8", "surrogateescape") class MessageData(utils.Serializable): |