from mitmproxy import http def request(flow: http.HTTPFlow) -> None: # Check if the content length is 0 if "content-length" in flow.request.headers and int(flow.request.headers["content-length"]) == 0: # Modify the response to be SOAP format flow.response = http.HTTPResponse.make( 200, # HTTP status code b'Hello from SOAP!', # Response content in SOAP format {"Content-Type": "application/xml"} # Response headers ) addons = [ # Add the request handler http.HTTPFlowHook(request) ]