Intercept but don't forward via script?

I’m currently intercepting request content via a simple py script, but it would like to drop the forwarding afterwards (or empty the request content before forwarding), so I tried with flow.request.content = null after I grabbed that content via my script, but it does not seem to work.

Is it possible to modify the intercepted request before it gets forwarded anyway, or is this something that has to be done via the UI and if it would drop that request via the API will the script be able to receive it before it gets dropped?

Hi, currently interested in this too.

From my understanding of the design, the events are passed onto the scripts through the event callbacks. See here:Events

I haven’t seen a way to communicate a ‘drop request’ or ‘respond-to-request-with’ message back to the controller though. Would like that too, as it would let me change some of the script parameters via an http call, either to a fake host (http://foo.bar) or to the proxy’s address (http://mitm.it)

DD

Are you guys perhaps looking for our [redirect_requests.py] (https://github.com/mitmproxy/mitmproxy/blob/ea2d6474bf1e9c4c1fd2e4a6ac33e0785fc751de/examples/redirect_requests.py) example?

You can modify all aspects of a request before forwarding it to the server or killing it entirely.