Search code examples
pythonpython-3.xmitmproxy

how to simulate timeout in mitmproxy addon?


mitmproxy is a library in Python (python-3.x) to monitor, manipulate, and debug HTTP protocol. It encapsulates an HTTP request into a Flow object and allows to manipulate them via addons.

I wanna stop a flow if it matches a condition. So the client will wait for a time and get a timeout response.

It does not matter in which event it must be handled.


Solution

  • The flow object consists of utilities to do so. Jus kill and set error message as follow:

            flow.kill()
            flow.client_conn.error = "Connection killed by an addon."