diff options
Diffstat (limited to 'mitmproxy/contentviews.py')
-rw-r--r-- | mitmproxy/contentviews.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index ed6acfc1..24c4d396 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -15,11 +15,15 @@ requests, the query parameters are passed as the ``query`` keyword argument. from __future__ import absolute_import, print_function, division import datetime +import io import json import logging import subprocess import traceback -from typing import Mapping, Union, Generator, Tuple +from typing import Generator +from typing import Mapping +from typing import Tuple +from typing import Union import cssutils import html2text @@ -34,7 +38,6 @@ from netlib import http from netlib import multidict from netlib import strutils from netlib.http import url -from six import BytesIO try: import pyamf @@ -42,7 +45,6 @@ try: except ImportError: # pragma no cover pyamf = None - # Default view cutoff *in lines* VIEW_CUTOFF = 512 @@ -300,7 +302,6 @@ class ViewMultipart(View): if pyamf: class DummyObject(dict): - def __init__(self, alias): dict.__init__(self) @@ -308,6 +309,7 @@ if pyamf: data = input.readObject() self["data"] = data + def pyamf_class_loader(s): for i in pyamf.CLASS_LOADERS: if i != pyamf_class_loader: @@ -316,8 +318,10 @@ if pyamf: return v return DummyObject + pyamf.register_class_loader(pyamf_class_loader) + class ViewAMF(View): name = "AMF" prompt = ("amf", "f") @@ -423,7 +427,7 @@ class ViewImage(View): def __call__(self, data, **metadata): try: - img = Image.open(BytesIO(data)) + img = Image.open(io.BytesIO(data)) except IOError: return None parts = [ @@ -449,7 +453,6 @@ class ViewImage(View): class ViewProtobuf(View): - """Human friendly view of protocol buffers The view uses the protoc compiler to decode the binary """ @@ -513,7 +516,6 @@ class ViewWBXML(View): ] def __call__(self, data, **metadata): - try: parser = ASCommandResponse.ASCommandResponse(data) parsedContent = parser.xmlString |