diff options
Diffstat (limited to 'netlib/http/message.py')
| -rw-r--r-- | netlib/http/message.py | 17 | 
1 files changed, 12 insertions, 5 deletions
| diff --git a/netlib/http/message.py b/netlib/http/message.py index b7f42515..13d401a7 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -6,14 +6,21 @@ import six  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): | 
