示例#1
0
 def __call__(self, data, **metadata):
     data = parse_json(data)
     if data is not PARSE_ERROR:
         if is_graphql_query(data):
             return "GraphQL", base.format_text(format_graphql(data))
         elif is_graphql_batch_query(data):
             return "GraphQL", base.format_text(format_query_list(data))
示例#2
0
 def __call__(self, data, **metadata):
     data = data.decode("utf-8", "replace")
     h = html2text.HTML2Text(baseurl="")
     h.ignore_images = True
     h.body_width = 0
     outline = h.handle(data)
     return "HTML Outline", base.format_text(outline)
示例#3
0
 def __call__(self, data, **metadata):
     # TODO:
     # We should really have the message text as str here,
     # not the message content as bytes.
     # https://github.com/mitmproxy/mitmproxy/issues/1662#issuecomment-266192578
     data = data.decode("utf8", "xmlcharrefreplace")
     tokens = tokenize(data)
     # TODO:
     # Performance: Don't render the whole document right away.
     # Let's wait with this until we have a sequence-like interface,
     # this thing is reasonably fast right now anyway.
     pretty = base.format_text(format_xml(tokens))
     if "html" in data.lower():
         t = "HTML"
     else:
         t = "XML"
     return t, pretty
示例#4
0
 def __call__(self, data, **metadata):
     # TODO:
     # We should really have the message text as str here,
     # not the message content as bytes.
     # https://github.com/mitmproxy/mitmproxy/issues/1662#issuecomment-266192578
     data = data.decode("utf8", "xmlcharrefreplace")
     tokens = tokenize(data)
     # TODO:
     # Performance: Don't render the whole document right away.
     # Let's wait with this until we have a sequence-like interface,
     # this thing is reasonably fast right now anyway.
     pretty = base.format_text(format_xml(tokens))
     if "html" in data.lower():
         t = "HTML"
     else:
         t = "XML"
     return t, pretty
示例#5
0
 def __call__(self, data, **metadata):
     data = data.decode("utf8", "surrogateescape")
     beautified = beautify(data)
     return "CSS", base.format_text(beautified)
示例#6
0
 def __call__(self, data, **metadata):
     data = data.decode("utf-8", "replace")
     res = beautify(data)
     return "JavaScript", base.format_text(res)
示例#7
0
 def __call__(self, data, **metadata):
     data = data.decode("utf-8", "replace")
     res = beautify(data)
     return "JavaScript", base.format_text(res)
示例#8
0
文件: css.py 项目: cortesi/mitmproxy
 def __call__(self, data, **metadata):
     data = data.decode("utf8", "surrogateescape")
     beautified = beautify(data)
     return "CSS", base.format_text(beautified)
示例#9
0
 def __call__(self, data, **metadata):
     pj = pretty_json(data)
     if pj:
         return "JSON", base.format_text(pj)
示例#10
0
 def __call__(self, data, **metadata):
     pj = pretty_json(data)
     if pj:
         return "JSON", base.format_text(pj)
示例#11
0
文件: msgpack.py 项目: tasn/mitmproxy
def format_msgpack(data):
    return base.format_text(pretty(data))