aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/encoding.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-17 16:31:50 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-17 16:31:50 +0200
commitd798ed955dab4681a5285024b3648b1a3f13c24e (patch)
treea95d96953cd7688451c3a515e4b31f0465d6a7d3 /netlib/encoding.py
parent8d71059d77c2dd1d9858d7971dd0b6b4387ed9f4 (diff)
downloadmitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.tar.gz
mitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.tar.bz2
mitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.zip
python3++
Diffstat (limited to 'netlib/encoding.py')
-rw-r--r--netlib/encoding.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/netlib/encoding.py b/netlib/encoding.py
index 06830f2c..8ac59905 100644
--- a/netlib/encoding.py
+++ b/netlib/encoding.py
@@ -5,28 +5,30 @@ from __future__ import absolute_import
from io import BytesIO
import gzip
import zlib
+from .utils import always_byte_args
-__ALL__ = ["ENCODINGS"]
-ENCODINGS = {"identity", "gzip", "deflate"}
+ENCODINGS = {b"identity", b"gzip", b"deflate"}
+@always_byte_args("ascii", "ignore")
def decode(e, content):
encoding_map = {
- "identity": identity,
- "gzip": decode_gzip,
- "deflate": decode_deflate,
+ b"identity": identity,
+ b"gzip": decode_gzip,
+ b"deflate": decode_deflate,
}
if e not in encoding_map:
return None
return encoding_map[e](content)
+@always_byte_args("ascii", "ignore")
def encode(e, content):
encoding_map = {
- "identity": identity,
- "gzip": encode_gzip,
- "deflate": encode_deflate,
+ b"identity": identity,
+ b"gzip": encode_gzip,
+ b"deflate": encode_deflate,
}
if e not in encoding_map:
return None
@@ -80,3 +82,5 @@ def encode_deflate(content):
Returns compressed content, always including zlib header and checksum.
"""
return zlib.compress(content)
+
+__all__ = ["ENCODINGS", "encode", "decode"]