I'm trying to replicate the functionality provided by the Map Remote feature in Charles using MITMPROXY on OS X 10.9. What I want to do is replace any request for desiredurl.com with a request for desiredurl.ca (I'm open to any answer which tells me how to replicate the given functionality in Charles using free software).
I found this answer and this question which both looked like they should help, and I wrote the below script.
#!/usr/bin/env python
def redirect_request(context, flow):
host = flow.get_url()
if 'desiredurl' in host:
flow.set_url(host.replace('com','ca'))
I mitmdump -s path/to/script.py
on my iMac and then connect my iPad to my iMac on port 8080 as usual, and see the traffic flying by in the Terminal window, but visiting desiredurl.com still takes me to desiredurl.com rather than desiredurl.ca. Thus, I tried the following:
#!/usr/bin/env python
def response(context, flow):
if 'desiredurl' in flow.request.host:
flow.request.host.replace('com','ca')
However, the requests still go to desiredurl.com rather than desiredurl.ca. Why is this?