diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-08-20 16:01:01 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-08-20 16:01:01 +0530 |
commit | 41e4526a332991ab7c8d03fca246c9117cccfadc (patch) | |
tree | 675394e7e3c0eeab38543de2a6814208fe828ffe | |
parent | 22283dd37346dcc62a68e9a1c520638cbbbfa869 (diff) | |
download | mitmproxy-41e4526a332991ab7c8d03fca246c9117cccfadc.tar.gz mitmproxy-41e4526a332991ab7c8d03fca246c9117cccfadc.tar.bz2 mitmproxy-41e4526a332991ab7c8d03fca246c9117cccfadc.zip |
Use terminal width rather than a constant
-rw-r--r-- | mitmproxy/console/common.py | 12 | ||||
-rw-r--r-- | mitmproxy/console/flowlist.py | 4 | ||||
-rw-r--r-- | mitmproxy/console/flowview.py | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/mitmproxy/console/common.py b/mitmproxy/console/common.py index b514e43f..e9359109 100644 --- a/mitmproxy/console/common.py +++ b/mitmproxy/console/common.py @@ -32,8 +32,6 @@ METHOD_OPTIONS = [ ("edit raw", "e"), ] -MAX_URL_LEN = 200 - def is_keypress(k): """ @@ -330,7 +328,7 @@ def export_to_clip_or_file(key, scope, flow, writer): flowcache = utils.LRUCache(800) -def raw_format_flow(f, focus, extended, short_urls): +def raw_format_flow(f, focus, extended, truncate_urls): f = dict(f) pile = [] req = [] @@ -363,8 +361,8 @@ def raw_format_flow(f, focus, extended, short_urls): 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 truncate_urls and len(url) > truncate_urls: + url = url[:truncate_urls] + "..." if f["req_http_version"] not in ("HTTP/1.0", "HTTP/1.1"): url += " " + f["req_http_version"] @@ -417,7 +415,7 @@ def raw_format_flow(f, focus, extended, short_urls): return urwid.Pile(pile) -def format_flow(f, focus, extended=False, hostheader=False, short_urls=True): +def format_flow(f, focus, extended=False, hostheader=False, truncate_urls=False): d = dict( intercepted = f.intercepted, acked = f.reply.state == "committed", @@ -461,5 +459,5 @@ def format_flow(f, focus, extended=False, hostheader=False, short_urls=True): tuple(sorted(d.items())), focus, extended, - short_urls, + truncate_urls, ) diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py index 7e69e098..6e6f989f 100644 --- a/mitmproxy/console/flowlist.py +++ b/mitmproxy/console/flowlist.py @@ -116,10 +116,12 @@ class ConnectionItem(urwid.WidgetWrap): urwid.WidgetWrap.__init__(self, w) def get_text(self): + cols, _ = self.master.ui.get_cols_rows() return common.format_flow( self.flow, self.f, - hostheader = self.master.options.showhost, + hostheader=self.master.options.showhost, + truncate_urls=cols, ) def selectable(self): diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py index 0f54c7cb..482fd5ca 100644 --- a/mitmproxy/console/flowview.py +++ b/mitmproxy/console/flowview.py @@ -104,22 +104,24 @@ class FlowViewHeader(urwid.WidgetWrap): def __init__(self, master, f): self.master = master # type: "mitmproxy.console.master.ConsoleMaster" self.flow = f # type: models.HTTPFlow + cols, _ = self.master.ui.get_cols_rows() self._w = common.format_flow( f, False, extended=True, - short_urls=False, + truncate_urls=cols, hostheader=self.master.options.showhost ) signals.flow_change.connect(self.sig_flow_change) def sig_flow_change(self, sender, flow): + cols, _ = self.master.ui.get_cols_rows() if flow == self.flow: self._w = common.format_flow( flow, False, extended=True, - short_urls=False, + truncate_urls=cols, hostheader=self.master.options.showhost ) |