I am using mitmdump with python script to intercept https request and manipulate flow.request.host
, flow.request.scheme
, flow.request.port
and flow.request.path
with in def request(flow):
. I have been able to achieve the same and get a response for the manipulated request. After first get response for first request, my application send a second request. In the second request, instead of the host and port set by my application, I get the same previously manipulated host and port that is flow.request.host
and flow.request.port
are from my last manipulated request but flow.request.scheme
and flow.request.path
are same as my application sets in second request.
Is there any way I can reset the flow.request.host
and flow.request.port
after every response, so that my next request is captured in flow.request
correctly?
from mitmproxy import http
import sys
def request(flow):
print("\nOriginal Request : " + str(flow.request)+"\n")
if flow.request.pretty_host.endswith("original.host.com"):
flow.request.host = "mock.host.com"
flow.request.scheme = "http"
flow.request.port = 8081
flow.request.path = re.sub(r"billing",r"moquer-0.0.2/mockbillingBinding",flow.request.path)
print("Manipulated Request : " + str(flow.request)+"\n")
def response(flow):
print("Response : " +str(flow.response)+"\n")