testsAndMisc/PYTHON/mock_server/mock_server.py

11 lines
343 B
Python
Raw Normal View History

2024-10-15 07:22:10 +02:00
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
# Only intercept traffic to example.com
if "example.com" in flow.request.host:
flow.response = http.Response.make(
502, # Bad Gateway status code
b"Simulated connection failure",
{"Content-Type": "text/plain"}
)