diff options
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/console.py | 8 | ||||
-rw-r--r-- | libmproxy/encoding.py | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py index c1e14b33..02f824ac 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -306,7 +306,8 @@ class ConnectionView(WWrap): else: e = "identity" return self.master._cached_conn_text( - encoding.decode(e, conn.content), + e, + conn.content, tuple([tuple(i) for i in conn.headers.lst]), viewmode ) @@ -965,7 +966,10 @@ class ConsoleMaster(flow.FlowMaster): return self._view_conn_raw(content, txt) @utils.LRUCache(20) - def _cached_conn_text(self, content, hdrItems, viewmode): + def _cached_conn_text(self, e, rawcontent, hdrItems, viewmode): + content = encoding.decode(e, rawcontent) + if content is None: + content = rawcontent hdr = [] hdr.extend( format_keyvals( diff --git a/libmproxy/encoding.py b/libmproxy/encoding.py index f280ed9f..b56c03a6 100644 --- a/libmproxy/encoding.py +++ b/libmproxy/encoding.py @@ -14,7 +14,6 @@ def decode(encoding, content): "gzip": decode_gzip, "deflate": decode_deflate, } - return encoding_map.get(encoding, decode_identity)(content) def decode_identity(content): @@ -26,7 +25,10 @@ def decode_identity(content): def decode_gzip(content): gfile = gzip.GzipFile(fileobj=cStringIO.StringIO(content)) - return gfile.read() + try: + return gfile.read() + except IOError: + return None def decode_deflate(content): """ @@ -38,6 +40,9 @@ def decode_deflate(content): http://bugs.python.org/issue5784 """ try: - return zlib.decompress(content) + try: + return zlib.decompress(content) + except zlib.error: + return zlib.decompress(content, -15) except zlib.error: - return zlib.decompress(content, -15)
\ No newline at end of file + return None |