title: Rewrite a domain in mitmproxy
body: <p>I have an Android app, which is making request to example.com.
  How can I setup mitmproxy such that all requests to example.com/etc/else will go to dev.example.com/etc/else?</p>
  
  <p>I tried this:</p>
  
  <p>My script (rewrite.py):</p>
  
  <pre><code>import mitmproxy
  from mitmproxy.models import HTTPResponse
  from netlib.http import Headers
  
  def request(context, flow):
      if 'example.com' in flow.request.url :
          flow.request.host = 'dev.example.com'
  </code></pre>
  
  <p>Also, for some reason I don't see logging output, for example:</p>
  
  <pre><code>from mitmproxy import ctx
   ...
  ctx.log.info("This is some informative text.")
  </code></pre>
  
  <p>I'm running mitmproxy like this:</p>
  
  <pre><code>mitmproxy -p 8765 -e -s rewrite.py
  </code></pre>