I am using the Mitmproxy scripting API while running in transparent mode to selectively handle some requests using the request() function. The script will handle some requests to the target server and others it will contact the server itself and pass the results on to the client. In no way does mitmproxt contact the target server in it’s default way.
I have found that if an error happens a request that would not have been passed through(by returning my own flow.response) does get handled in the default way as if the script was not there. It does not matter if the error happens in my script file or in mitmproxy itself.
How can I ensure that no matter what, mitmproxy does not send a request to the target server?