只有一个特定域的mitmproxy

2024-04-23 19:40:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这个python脚本(test.py):

from mitmproxy import http

OGG = open('testfile.ogg', 'rb').read()
SIZE = str(len(OGG))

def request(flow):
    flow.response = http.HTTPResponse.make(
        200,
        OGG,
        {'Content-Type'  : 'application/octet-stream',
'Content-Length': SIZE})

如果一个特定的域被请求,我想把HTTP应答发送给客户机,但是我不知道如何去做。最后,所有的HTTP请求都将用OGG文件来响应。在

我尝试了以下方法:

  • 我使用了这个命令:mitmproxy -T -p 8080 -s test.py -i "test.example.com"
  • 因为在mitmproxy中只显示IP地址,所以我尝试使用IP地址:mitmproxy -T -p 8080 -s test.py -i "93.184.216.34"

有人能回答吗?在


Tags: frompytestimport脚本httpsizeopen