title: Change URL to another URL using mitmproxy
body: <p>I am trying to redirect one page to another by using mitmproxy and Python. I can run my inline script together with mitmproxy without issues, but I am stuck when it comes to changing the URL to another URL. Like if I went to google.com it would redirect to stackoverflow.com</p>
  
  <pre><code>def response(context, flow):
          print("DEBUG")
          if flow.request.url.startswith("http://google.com/"):
              print("It does contain it")
              flow.request.url = "http://stackoverflow/"
  </code></pre>
  
  <p>This should in theory work. I see <code>http://google.com/</code> in the GUI of mitmproxy (as GET) but the <code>print("It does contain it")</code> never gets fired.</p>
  
  <p>When I try to just put <code>flow.request.url = "http://stackoverflow.com"</code> right under the <code>print("DEBUG")</code> it won't work neither.</p>
  
  <p>What am I doing wrong? I have also tried <code>if "google.com" in flow.request.url</code> to check if the URL contains <code>google.com</code> but that won't work either.</p>
  
  <p>Thanks</p>