aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/addons/dumper.py12
-rw-r--r--mitmproxy/options.py13
-rw-r--r--test/mitmproxy/addons/test_dumper.py14
-rw-r--r--test/mitmproxy/tools/test_dump.py2
4 files changed, 20 insertions, 21 deletions
diff --git a/mitmproxy/addons/dumper.py b/mitmproxy/addons/dumper.py
index 48bc8118..8cfacde6 100644
--- a/mitmproxy/addons/dumper.py
+++ b/mitmproxy/addons/dumper.py
@@ -31,6 +31,18 @@ class Dumper:
self.filter = None # type: flowfilter.TFilter
self.outfp = outfile # type: typing.io.TextIO
+ def load(self, loader):
+ loader.add_option(
+ "flow_detail", int, 1,
+ """
+ The display detail level for flows in mitmdump: 0 (almost quiet) to 3 (very verbose).
+ 0: shortened request URL, response status code, WebSocket and TCP message notifications.
+ 1: full request URL with response status code
+ 2: 1 + HTTP headers
+ 3: 2 + full response content, content of WebSocket and TCP messages.
+ """
+ )
+
def configure(self, updated):
if "view_filter" in updated:
if ctx.options.view_filter:
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index 70d454fd..139b197f 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -58,7 +58,6 @@ class Options(optmanager.OptManager):
# because they're used by more than one addon, or because they're
# embedded in the core code somehow.
default_contentview = None # type: str
- flow_detail = None # type: int
intercept = None # type: Optional[str]
intercept_active = None # type: bool
proxyauth = None # type: Optional[str]
@@ -267,16 +266,4 @@ class Options(optmanager.OptManager):
"Limit which flows are displayed."
)
- # Dump options
- self.add_option(
- "flow_detail", int, 1,
- """
- The display detail level for flows in mitmdump: 0 (almost quiet) to 3 (very verbose).
- 0: shortened request URL, response status code, WebSocket and TCP message notifications.
- 1: full request URL with response status code
- 2: 1 + HTTP headers
- 3: 2 + full response content, content of WebSocket and TCP messages.
- """
- )
-
self.update(**kwargs)
diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py
index 9774e131..ead6b7e7 100644
--- a/test/mitmproxy/addons/test_dumper.py
+++ b/test/mitmproxy/addons/test_dumper.py
@@ -14,7 +14,7 @@ from mitmproxy import http
def test_configure():
d = dumper.Dumper()
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, view_filter="~b foo")
assert d.filter
@@ -33,7 +33,7 @@ def test_configure():
def test_simple():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=0)
d.response(tflow.tflow(resp=True))
assert not sio.getvalue()
@@ -101,7 +101,7 @@ def test_echo_body():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3)
d._echo_message(f.response)
t = sio.getvalue()
@@ -111,7 +111,7 @@ def test_echo_body():
def test_echo_request_line():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.tflow(client_conn=None, server_conn=True, resp=True)
f.request.is_replay = True
@@ -146,7 +146,7 @@ class TestContentView:
view_auto.side_effect = exceptions.ContentViewException("")
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=4, verbosity='debug')
d.response(tflow.tflow())
assert ctx.master.has_log("content viewer failed")
@@ -155,7 +155,7 @@ class TestContentView:
def test_tcp():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.ttcpflow()
d.tcp_message(f)
@@ -170,7 +170,7 @@ def test_tcp():
def test_websocket():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.twebsocketflow()
d.websocket_message(f)
diff --git a/test/mitmproxy/tools/test_dump.py b/test/mitmproxy/tools/test_dump.py
index 952c3f4f..f303c808 100644
--- a/test/mitmproxy/tools/test_dump.py
+++ b/test/mitmproxy/tools/test_dump.py
@@ -11,7 +11,7 @@ from .. import tservers
class TestDumpMaster(tservers.MasterTest):
def mkmaster(self, flt, **opts):
- o = options.Options(view_filter=flt, verbosity='error', flow_detail=0, **opts)
+ o = options.Options(view_filter=flt, verbosity='error', **opts)
m = dump.DumpMaster(o, with_termlog=False, with_dumper=False)
return m