replace get_content_view in dumper and flowview

This commit is contained in:
Clemens 2016-08-01 15:21:00 +02:00
parent cb7da1ee44
commit bcc496527e
2 changed files with 7 additions and 43 deletions

View File

@ -73,20 +73,10 @@ 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(
highlight=dict(bold=True),

View File

@ -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")
)
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])
description, lines = contentviews.get_content_view_with_message_encoding(
message, viewmode
)
# 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)"