aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-08-20 14:52:22 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-08-20 16:00:50 +0530
commit22283dd37346dcc62a68e9a1c520638cbbbfa869 (patch)
tree0544ea3dbb096221d0a4c2a47a67589e280af549
parentcacee3871c6a9f0be7127f3c790e09a1daaf8490 (diff)
downloadmitmproxy-22283dd37346dcc62a68e9a1c520638cbbbfa869.tar.gz
mitmproxy-22283dd37346dcc62a68e9a1c520638cbbbfa869.tar.bz2
mitmproxy-22283dd37346dcc62a68e9a1c520638cbbbfa869.zip
Truncate URLs in console
-rw-r--r--mitmproxy/console/common.py16
-rw-r--r--mitmproxy/console/flowview.py2
2 files changed, 15 insertions, 3 deletions
diff --git a/mitmproxy/console/common.py b/mitmproxy/console/common.py
index 5a24e789..b514e43f 100644
--- a/mitmproxy/console/common.py
+++ b/mitmproxy/console/common.py
@@ -32,6 +32,8 @@ METHOD_OPTIONS = [
("edit raw", "e"),
]
+MAX_URL_LEN = 200
+
def is_keypress(k):
"""
@@ -328,7 +330,7 @@ def export_to_clip_or_file(key, scope, flow, writer):
flowcache = utils.LRUCache(800)
-def raw_format_flow(f, focus, extended):
+def raw_format_flow(f, focus, extended, short_urls):
f = dict(f)
pile = []
req = []
@@ -359,6 +361,11 @@ def raw_format_flow(f, focus, extended):
uc = "title"
url = f["req_url"]
+
+ # TODO: Add a configuration setting that disables this behaviour?
+ if short_urls and len(url) > MAX_URL_LEN:
+ url = url[:MAX_URL_LEN] + "..."
+
if f["req_http_version"] not in ("HTTP/1.0", "HTTP/1.1"):
url += " " + f["req_http_version"]
req.append(
@@ -410,7 +417,7 @@ def raw_format_flow(f, focus, extended):
return urwid.Pile(pile)
-def format_flow(f, focus, extended=False, hostheader=False):
+def format_flow(f, focus, extended=False, hostheader=False, short_urls=True):
d = dict(
intercepted = f.intercepted,
acked = f.reply.state == "committed",
@@ -451,5 +458,8 @@ def format_flow(f, focus, extended=False, hostheader=False):
d["resp_ctype"] = ""
return flowcache.get(
raw_format_flow,
- tuple(sorted(d.items())), focus, extended
+ tuple(sorted(d.items())),
+ focus,
+ extended,
+ short_urls,
)
diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py
index 6d74be65..0f54c7cb 100644
--- a/mitmproxy/console/flowview.py
+++ b/mitmproxy/console/flowview.py
@@ -108,6 +108,7 @@ class FlowViewHeader(urwid.WidgetWrap):
f,
False,
extended=True,
+ short_urls=False,
hostheader=self.master.options.showhost
)
signals.flow_change.connect(self.sig_flow_change)
@@ -118,6 +119,7 @@ class FlowViewHeader(urwid.WidgetWrap):
flow,
False,
extended=True,
+ short_urls=False,
hostheader=self.master.options.showhost
)