像标题一样,我想在“def request()”中处理数据,并直接返回响应;
我不想流经目标服务器;
这种方式可行吗?谢谢!!!
这是一个关于如何做到这一点的例子:
"""Send a reply from the proxy without sending any data to the remote server."""
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url == "http://example.com/path":
flow.response = http.Response.make(
200, # (optional) status code
b"Hello World", # (optional) content
{"Content-Type": "text/html"} # (optional) headers
)
来源:https : //github.com/mitmproxy/mitmproxy/blob/main/examples/addons/http-reply-from-proxy.py
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句