mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
replace get_content_view in dumper and flowview
This commit is contained in:
parent
cb7da1ee44
commit
bcc496527e
@ -73,19 +73,9 @@ class Dumper(object):
|
||||
elif content:
|
||||
self.echo("")
|
||||
|
||||
try:
|
||||
_, lines = contentviews.get_content_view(
|
||||
contentviews.get("Auto"),
|
||||
content,
|
||||
headers=getattr(message, "headers", None)
|
||||
)
|
||||
except exceptions.ContentViewException:
|
||||
s = "Content viewer failed: \n" + traceback.format_exc()
|
||||
ctx.log.debug(s)
|
||||
_, lines = contentviews.get_content_view(
|
||||
contentviews.get("Raw"),
|
||||
content,
|
||||
headers=getattr(message, "headers", None)
|
||||
_, lines = contentviews.get_content_view_with_message_encoding(
|
||||
message,
|
||||
contentviews.get("Auto")
|
||||
)
|
||||
|
||||
styles = dict(
|
||||
|
@ -207,35 +207,9 @@ class FlowView(tabs.Tabs):
|
||||
|
||||
def _get_content_view(self, message, viewmode, max_lines, _):
|
||||
|
||||
try:
|
||||
content = message.content
|
||||
if content != message.raw_content:
|
||||
enc = "[decoded {}]".format(
|
||||
message.headers.get("content-encoding")
|
||||
description, lines = contentviews.get_content_view_with_message_encoding(
|
||||
message, viewmode
|
||||
)
|
||||
else:
|
||||
enc = None
|
||||
except ValueError:
|
||||
content = message.raw_content
|
||||
enc = "[cannot decode]"
|
||||
try:
|
||||
query = None
|
||||
if isinstance(message, models.HTTPRequest):
|
||||
query = message.query
|
||||
description, lines = contentviews.get_content_view(
|
||||
viewmode, content, headers=message.headers, query=query
|
||||
)
|
||||
except exceptions.ContentViewException:
|
||||
s = "Content viewer failed: \n" + traceback.format_exc()
|
||||
signals.add_log(s, "error")
|
||||
description, lines = contentviews.get_content_view(
|
||||
contentviews.get("Raw"), content, headers=message.headers
|
||||
)
|
||||
description = description.replace("Raw", "Couldn't parse: falling back to Raw")
|
||||
|
||||
if enc:
|
||||
description = " ".join([enc, description])
|
||||
|
||||
# Give hint that you have to tab for the response.
|
||||
if description == "No content" and isinstance(message, models.HTTPRequest):
|
||||
description = "No request content (press tab to view response)"
|
||||
|
Loading…
Reference in New Issue
Block a user