aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_encoding.py
diff options
context:
space:
mode:
authoralts <stephen@evilrobotstuff.com>2011-07-16 02:47:06 -0700
committeralts <stephen@evilrobotstuff.com>2011-07-16 02:47:06 -0700
commit6dc0f105ccabeb10f557dc8baa51d3ce08b3c8ee (patch)
tree977c6339d1562a333b1d2087853248ea5ed32771 /test/test_encoding.py
parent94ae720a220da4beaa2fc6111b4cafb60b41d33b (diff)
downloadmitmproxy-6dc0f105ccabeb10f557dc8baa51d3ce08b3c8ee.tar.gz
mitmproxy-6dc0f105ccabeb10f557dc8baa51d3ce08b3c8ee.tar.bz2
mitmproxy-6dc0f105ccabeb10f557dc8baa51d3ce08b3c8ee.zip
Adds support for content encoding, namely gip and deflate
Diffstat (limited to 'test/test_encoding.py')
-rw-r--r--test/test_encoding.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_encoding.py b/test/test_encoding.py
new file mode 100644
index 00000000..ba0755d6
--- /dev/null
+++ b/test/test_encoding.py
@@ -0,0 +1,31 @@
+from libmproxy import encoding
+import libpry
+
+import cStringIO
+import gzip, zlib
+
+class udecode_identity(libpry.AutoTree):
+ def test_decode(self):
+ assert 'string' == encoding.decode('identity', 'string')
+
+ def test_fallthrough(self):
+ assert 'string' == encoding.decode('nonexistent encoding', 'string')
+
+class udecode_gzip(libpry.AutoTree):
+ def test_simple(self):
+ s = cStringIO.StringIO()
+ gf = gzip.GzipFile(fileobj=s, mode='wb')
+ gf.write('string')
+ gf.close()
+ assert 'string' == encoding.decode('gzip', s.getvalue())
+
+class udecode_deflate(libpry.AutoTree):
+ def test_simple(self):
+ assert 'string' == encoding.decode('deflate', zlib.compress('string'))
+ assert 'string' == encoding.decode('deflate', zlib.compress('string')[2:-4])
+
+tests = [
+ udecode_identity(),
+ udecode_gzip(),
+ udecode_deflate()
+]