diff --git a/mitmproxy/contentviews/__init__.py b/mitmproxy/contentviews/__init__.py index 7810535e8..01c6d221f 100644 --- a/mitmproxy/contentviews/__init__.py +++ b/mitmproxy/contentviews/__init__.py @@ -24,7 +24,7 @@ from . import ( auto, raw, hex, json, xml_html, wbxml, javascript, css, urlencoded, multipart, image, query, protobuf ) -from .base import View, VIEW_CUTOFF, KEY_MAX, format_text, format_dict, TViewResult +from .base import View, KEY_MAX, format_text, format_dict, TViewResult views: List[View] = [] content_types_map: Dict[str, List[View]] = {} @@ -160,6 +160,6 @@ add(query.ViewQuery()) add(protobuf.ViewProtobuf()) __all__ = [ - "View", "VIEW_CUTOFF", "KEY_MAX", "format_text", "format_dict", "TViewResult", + "View", "KEY_MAX", "format_text", "format_dict", "TViewResult", "get", "add", "remove", "get_content_view", "get_message_content_view", ] diff --git a/mitmproxy/contentviews/base.py b/mitmproxy/contentviews/base.py index 260c7af83..e4ccf66f7 100644 --- a/mitmproxy/contentviews/base.py +++ b/mitmproxy/contentviews/base.py @@ -1,8 +1,6 @@ # Default view cutoff *in lines* import typing -VIEW_CUTOFF = 512 - KEY_MAX = 30 TTextType = typing.Union[str, bytes] # FIXME: This should be either bytes or str ultimately. diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 047a44cd7..a6ab3d504 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -6,6 +6,7 @@ from mitmproxy.net import tls CONF_DIR = "~/.mitmproxy" LISTEN_PORT = 8080 +CONTENT_VIEW_LINES_CUTOFF = 512 class Options(optmanager.OptManager): @@ -161,5 +162,12 @@ class Options(optmanager.OptManager): communication contents are printed to the log in verbose mode. """ ) + self.add_option( + "content_view_lines_cutoff", int, CONTENT_VIEW_LINES_CUTOFF, + """ + Flow content view lines limit. Limit is enabled by default to + speedup flows browsing. + """ + ) self.update(**kwargs) diff --git a/mitmproxy/tools/console/flowview.py b/mitmproxy/tools/console/flowview.py index 87671c3bc..b4e3876f1 100644 --- a/mitmproxy/tools/console/flowview.py +++ b/mitmproxy/tools/console/flowview.py @@ -6,6 +6,7 @@ from typing import Optional, Union # noqa import urwid from mitmproxy import contentviews +from mitmproxy import ctx from mitmproxy import http from mitmproxy.tools.console import common from mitmproxy.tools.console import layoutwidget @@ -102,7 +103,7 @@ class FlowDetails(tabs.Tabs): if full == "true": limit = sys.maxsize else: - limit = contentviews.VIEW_CUTOFF + limit = ctx.options.content_view_lines_cutoff flow_modify_cache_invalidation = hash(( message.raw_content,