diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-16 00:13:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-16 00:13:58 -0700 |
commit | b27d59095d799436fed41eaeaba502ecceb40f76 (patch) | |
tree | 152440c1e22850b81aa115817bee4d661f2435de /mitmproxy/dump.py | |
parent | 903807292b42b2481a3d72d6dbdc72939fc39b01 (diff) | |
parent | e6e39ce80f4daaf6a1d6f8d87616409486d358a5 (diff) | |
download | mitmproxy-b27d59095d799436fed41eaeaba502ecceb40f76.tar.gz mitmproxy-b27d59095d799436fed41eaeaba502ecceb40f76.tar.bz2 mitmproxy-b27d59095d799436fed41eaeaba502ecceb40f76.zip |
Merge pull request #1306 from mitmproxy/message-body-encoding
Improve Message Body Encoding
Diffstat (limited to 'mitmproxy/dump.py')
-rw-r--r-- | mitmproxy/dump.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index de63ca10..e7cebf99 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -143,15 +143,20 @@ class DumpMaster(flow.FlowMaster): ) self.echo(headers, indent=4) if self.options.flow_detail >= 3: - if message.content is None: + try: + content = message.content + except ValueError: + content = message.get_content(strict=False) + + if content is None: self.echo("(content missing)", indent=4) - elif message.content: + elif content: self.echo("") try: type, lines = contentviews.get_content_view( contentviews.get("Auto"), - message.content, + content, headers=getattr(message, "headers", None) ) except exceptions.ContentViewException: @@ -159,7 +164,7 @@ class DumpMaster(flow.FlowMaster): self.add_log(s, "debug") type, lines = contentviews.get_content_view( contentviews.get("Raw"), - message.content, + content, headers=getattr(message, "headers", None) ) @@ -248,10 +253,10 @@ class DumpMaster(flow.FlowMaster): code = click.style(str(code), fg=code_color, bold=True, blink=(code == 418)) reason = click.style(strutils.escape_control_characters(flow.response.reason), fg=code_color, bold=True) - if flow.response.content is None: + if flow.response.raw_content is None: size = "(content missing)" else: - size = human.pretty_size(len(flow.response.content)) + size = human.pretty_size(len(flow.response.raw_content)) size = click.style(size, bold=True) arrows = click.style("<<", bold=True) |