我有一个Android应用,它向example.com发出请求。 如何设置mitmproxy,以便对example.com/etc/else的所有请求都转到dev.example.com/etc/else?
我试过了:
我的脚本(rewrite.py):
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'
另外,由于某种原因,我没有看到日志记录输出,例如:
from mitmproxy import ctx
...
ctx.log.info("This is some informative text.")
我正在运行这样的mitmproxy:
mitmproxy -p 8765 -e -s rewrite.py
答案 0 :(得分:0)
因此,对于mitmproxy v0.18.2,解决方案是:
import mitmproxy
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
from mitmproxy import ctx
def request( flow):
if flow.request.pretty_host.endswith('example.com'):
flow.request.host = 'dev.example.com'
flow.request.scheme = 'http'
flow.request.port = 80
ctx.log.info(" --->" + flow.request.url)