使用带有以下代码的 mitmproxy 时,我正在尝试返回自定义响应
from libmproxy.models import HTTPResponse
from netlib.http import Headers
def request(context, flow):
if flow.request.pretty_url.endswith("example.com/index.php"):
resp = HTTPResponse(
[1, 1], 200, "OK",
Headers(Content_Type="text/html"),
"<html><body>hello world</body></html>")
flow.reply(resp)
但是结果并不像预期的那样,在浏览器中它显示为 http 状态代码,标题 och 正文为明文
[1,1] 200 OK
Content-Type: text/html
<html><body>hello world</body></html>
如何将其作为实际的“http”响应返回,以便 chrome 将其呈现为 html?