aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/dump.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-07-14 14:09:59 +1200
committerGitHub <noreply@github.com>2016-07-14 14:09:59 +1200
commitb8a23eeaa3c1555ae260fa21b045f002d9467bc8 (patch)
tree3496f88cbcfa1e7c2470e3e1bed9ac67bb563bdb /mitmproxy/dump.py
parent941919190bfd8e63129b5da9baa061e60a0547fd (diff)
parentb2c4f301cb834ecdf6e5b0063e86be877d3ece6d (diff)
downloadmitmproxy-b8a23eeaa3c1555ae260fa21b045f002d9467bc8.tar.gz
mitmproxy-b8a23eeaa3c1555ae260fa21b045f002d9467bc8.tar.bz2
mitmproxy-b8a23eeaa3c1555ae260fa21b045f002d9467bc8.zip
Merge pull request #1353 from cortesi/stream
Streaming to file -> addon
Diffstat (limited to 'mitmproxy/dump.py')
-rw-r--r--mitmproxy/dump.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py
index d9142a4d..296419db 100644
--- a/mitmproxy/dump.py
+++ b/mitmproxy/dump.py
@@ -52,16 +52,17 @@ class Options(options.Options):
"replay_ignore_content",
"replay_ignore_params",
"replay_ignore_payload_params",
- "replay_ignore_host"
+ "replay_ignore_host",
+
+ "tfile"
]
class DumpMaster(flow.FlowMaster):
- def __init__(self, server, options, outfile=None):
+ def __init__(self, server, options):
flow.FlowMaster.__init__(self, options, server, flow.State())
self.addons.add(*builtins.default_addons())
- self.outfile = outfile
self.o = options
self.showhost = options.showhost
self.replay_ignore_params = options.replay_ignore_params
@@ -82,15 +83,6 @@ class DumpMaster(flow.FlowMaster):
else:
self.filt = None
- if options.outfile:
- err = self.start_stream_to_path(
- options.outfile[0],
- options.outfile[1],
- self.filt
- )
- if err:
- raise DumpError(err)
-
if options.replacements:
for i in options.replacements:
self.replacehooks.add(*i)
@@ -163,7 +155,7 @@ class DumpMaster(flow.FlowMaster):
def echo(self, text, indent=None, **style):
if indent:
text = self.indent(indent, text)
- click.secho(text, file=self.outfile, **style)
+ click.secho(text, file=self.options.tfile, **style)
def _echo_message(self, message):
if self.options.flow_detail >= 2 and hasattr(message, "headers"):
@@ -312,8 +304,8 @@ class DumpMaster(flow.FlowMaster):
if f.error:
self.echo(" << {}".format(f.error.msg), bold=True, fg="red")
- if self.outfile:
- self.outfile.flush()
+ if self.options.tfile:
+ self.options.tfile.flush()
def _process_flow(self, f):
if self.filt and not f.match(self.filt):