本文整理汇总了Python中mitmproxy.models.HTTPResponse.make方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPResponse.make方法的具体用法?Python HTTPResponse.make怎么用?Python HTTPResponse.make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mitmproxy.models.HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse.make方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request
# 需要导入模块: from mitmproxy.models import HTTPResponse [as 别名]
# 或者: from mitmproxy.models.HTTPResponse import make [as 别名]
def request(flow):
# pretty_host takes the "Host" header of the request into account,
# which is useful in transparent mode where we usually only have the IP
# otherwise.
# Method 1: Answer with a locally generated response
if flow.request.pretty_host.endswith("example.com"):
resp = HTTPResponse.make(200, b"Hello World", {"Content-Type": "text/html"})
flow.reply.send(resp)
# Method 2: Redirect the request to a different server
if flow.request.pretty_host.endswith("example.org"):
flow.request.host = "mitmproxy.org"