aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-08-18 18:14:30 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-08-18 18:14:30 +1200
commit53e453f72ede3b99fc36aca998ec78f8c186de1c (patch)
tree3c8a3c0265da8422711e9a0694bfc92eda23a68f /libmproxy/console
parent15e234558dc3ca2e7fb3a3ef73211994bf541584 (diff)
downloadmitmproxy-53e453f72ede3b99fc36aca998ec78f8c186de1c.tar.gz
mitmproxy-53e453f72ede3b99fc36aca998ec78f8c186de1c.tar.bz2
mitmproxy-53e453f72ede3b99fc36aca998ec78f8c186de1c.zip
Use the new ODict get_first convenience function in a bunch of places.
Diffstat (limited to 'libmproxy/console')
-rw-r--r--libmproxy/console/contentview.py18
-rw-r--r--libmproxy/console/flowview.py4
2 files changed, 10 insertions, 12 deletions
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py
index 4b934ed5..e5881b6b 100644
--- a/libmproxy/console/contentview.py
+++ b/libmproxy/console/contentview.py
@@ -50,11 +50,9 @@ class ViewAuto:
prompt = ("auto", "a")
content_types = []
def __call__(self, hdrs, content, limit):
- ctype = hdrs.get("content-type")
+ ctype = hdrs.get_first("content-type")
if ctype:
- ctype = ctype[0]
- ct = utils.parse_content_type(ctype) if ctype else None
- if ct:
+ ct = utils.parse_content_type(ctype) if ctype else None
ct = "%s/%s"%(ct[0], ct[1])
if ct in content_types_map:
return content_types_map[ct][0](hdrs, content, limit)
@@ -199,9 +197,9 @@ class ViewMultipart:
prompt = ("multipart", "m")
content_types = ["multipart/form-data"]
def __call__(self, hdrs, content, limit):
- v = hdrs.get("content-type")
+ v = hdrs.get_first("content-type")
if v:
- v = utils.parse_content_type(v[0])
+ v = utils.parse_content_type(v)
if not v:
return
boundary = v[2].get("boundary")
@@ -363,12 +361,12 @@ def get_content_view(viewmode, hdrItems, content, limit, logfunc):
hdrs = flow.ODictCaseless([list(i) for i in hdrItems])
- enc = hdrs.get("content-encoding")
- if enc and enc[0] != "identity":
- decoded = encoding.decode(enc[0], content)
+ enc = hdrs.get_first("content-encoding")
+ if enc and enc != "identity":
+ decoded = encoding.decode(enc, content)
if decoded:
content = decoded
- msg.append("[decoded %s]"%enc[0])
+ msg.append("[decoded %s]"%enc)
try:
ret = viewmode(hdrs, content, limit)
# Third-party viewers can fail in unexpected ways...
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index a6ee41eb..0106e075 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -555,8 +555,8 @@ class FlowView(common.WWrap):
elif key == "z":
if conn:
self.flow.backup()
- e = conn.headers["content-encoding"] or ["identity"]
- if e[0] != "identity":
+ e = conn.headers.get_first("content-encoding", "identity")
+ if e != "identity":
conn.decode()
else:
self.master.prompt_onekey(