aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/contentview.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-11 12:13:39 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-11 12:13:39 +0200
commit7c186a4edbb0c6bc1f471d0db62dfc60008160a2 (patch)
tree89fb7e5b14cdfe9a0b61da828ddac8f355a3cdd0 /libmproxy/contentview.py
parentb62498e125191beca3b49841eb5f1fb9a93a868a (diff)
parentdd414e485212e3cab612a66d5d858c1a766ace04 (diff)
downloadmitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.tar.gz
mitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.tar.bz2
mitmproxy-7c186a4edbb0c6bc1f471d0db62dfc60008160a2.zip
Merge branch 'master' into contentviews
Diffstat (limited to 'libmproxy/contentview.py')
-rw-r--r--libmproxy/contentview.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/libmproxy/contentview.py b/libmproxy/contentview.py
index 45c1f2f1..a9b6cf95 100644
--- a/libmproxy/contentview.py
+++ b/libmproxy/contentview.py
@@ -9,14 +9,13 @@ import lxml.html
import lxml.etree
from PIL import Image
from PIL.ExifTags import TAGS
-import urwid
import html2text
import netlib.utils
-from netlib import odict, encoding
from . import utils
from .contrib import jsbeautifier
from .contrib.wbxml.ASCommandResponse import ASCommandResponse
+from netlib import encoding
try:
import pyamf
@@ -129,7 +128,7 @@ class ViewAuto(View):
content_types = []
def __call__(self, hdrs, content, limit):
- ctype = hdrs.get_first("content-type")
+ ctype = hdrs.get("content-type")
if ctype:
ct = netlib.utils.parse_content_type(ctype) if ctype else None
ct = "%s/%s" % (ct[0], ct[1])
@@ -536,7 +535,7 @@ def get(name):
return i
-def get_content_view(viewmode, hdrItems, content, limit, is_request, log=None):
+def get_content_view(viewmode, headers, content, limit, is_request, log=None):
"""
Returns:
A (msg, body) tuple.
@@ -551,16 +550,14 @@ def get_content_view(viewmode, hdrItems, content, limit, is_request, log=None):
return "No content", ""
msg = []
- hdrs = odict.ODictCaseless([list(i) for i in hdrItems])
-
- enc = hdrs.get_first("content-encoding")
+ enc = headers.get("content-encoding")
if enc and enc != "identity":
decoded = encoding.decode(enc, content)
if decoded:
content = decoded
msg.append("[decoded %s]" % enc)
try:
- ret = viewmode(hdrs, content, limit)
+ ret = viewmode(headers, content, limit)
# Third-party viewers can fail in unexpected ways...
except Exception:
if log:
@@ -569,7 +566,7 @@ def get_content_view(viewmode, hdrItems, content, limit, is_request, log=None):
log(s, "error")
ret = None
if not ret:
- ret = get("Raw")(hdrs, content, limit)
+ ret = get("Raw")(headers, content, limit)
msg.append("Couldn't parse: falling back to Raw")
else:
msg.append(ret[0])