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))
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)
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
def __call__(self, data, **metadata): data = data.decode("utf8", "surrogateescape") beautified = beautify(data) return "CSS", base.format_text(beautified)
def __call__(self, data, **metadata): data = data.decode("utf-8", "replace") res = beautify(data) return "JavaScript", base.format_text(res)
def __call__(self, data, **metadata): pj = pretty_json(data) if pj: return "JSON", base.format_text(pj)
def format_msgpack(data): return base.format_text(pretty(data))