aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/headers.py
diff options
context:
space:
mode:
Diffstat (limited to 'netlib/http/headers.py')
-rw-r--r--netlib/http/headers.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/netlib/http/headers.py b/netlib/http/headers.py
index 1511ea2d..613beb4f 100644
--- a/netlib/http/headers.py
+++ b/netlib/http/headers.py
@@ -14,16 +14,16 @@ except ImportError: # Workaround for Python < 3.3
import six
-from netlib.utils import always_byte_args
+from netlib.utils import always_byte_args, always_bytes
if six.PY2:
_native = lambda x: x
- _asbytes = lambda x: x
+ _always_bytes = lambda x: x
_always_byte_args = lambda x: x
else:
# While headers _should_ be ASCII, it's not uncommon for certain headers to be utf-8 encoded.
_native = lambda x: x.decode("utf-8", "surrogateescape")
- _asbytes = lambda x: x.encode("utf-8", "surrogateescape")
+ _always_bytes = lambda x: always_bytes(x, "utf-8", "surrogateescape")
_always_byte_args = always_byte_args("utf-8", "surrogateescape")
@@ -95,9 +95,9 @@ class Headers(MutableMapping, object):
# content_type -> content-type
headers = {
- _asbytes(name).replace(b"_", b"-"): value
+ _always_bytes(name).replace(b"_", b"-"): value
for name, value in six.iteritems(headers)
- }
+ }
self.update(headers)
def __bytes__(self):
@@ -183,7 +183,7 @@ class Headers(MutableMapping, object):
Explicitly set multiple headers for the given key.
See: :py:meth:`get_all`
"""
- values = map(_asbytes, values) # _always_byte_args does not fix lists
+ values = map(_always_bytes, values) # _always_byte_args does not fix lists
if name in self:
del self[name]
self.fields.extend(