MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / format_error

Function format_error

mitmproxy/proxy/layers/http/_base.py:43–61  ·  view source on GitHub ↗
(status_code: int, message: str)

Source from the content-addressed store, hash-verified

41
42
43def format_error(status_code: int, message: str) -> bytes:
44 reason = http.status_codes.RESPONSES.get(status_code, "Unknown")
45 return (
46 textwrap.dedent(
47 f"""
48 <html>
49 <head>
50 <title>{status_code} {reason}</title>
51 </head>
52 <body>
53 <h1>{status_code} {reason}</h1>
54 <p>{html.escape(message)}</p>
55 </body>
56 </html>
57 """
58 )
59 .strip()
60 .encode("utf8", "replace")
61 )

Callers 3

_handle_eventMethod · 0.85
_handle_eventMethod · 0.85
make_error_responseFunction · 0.85

Calls 2

getMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…