fix #253
This commit is contained in:
parent
9cba4f8d39
commit
a17a53269d
|
@ -1,18 +1,17 @@
|
|||
from libmproxy.flow import Response
|
||||
from libmproxy.protocol.http import HTTPResponse
|
||||
from netlib.odict import ODictCaseless
|
||||
|
||||
"""
|
||||
This example shows two ways to redirect flows to other destinations.
|
||||
"""
|
||||
|
||||
|
||||
def request(context, flow):
|
||||
if flow.request.host.endswith("example.com"):
|
||||
resp = Response(flow.request,
|
||||
[1,1],
|
||||
200, "OK",
|
||||
resp = HTTPResponse(
|
||||
[1, 1], 200, "OK",
|
||||
ODictCaseless([["Content-Type", "text/html"]]),
|
||||
"helloworld",
|
||||
None)
|
||||
"helloworld")
|
||||
flow.request.reply(resp)
|
||||
if flow.request.host.endswith("example.org"):
|
||||
flow.request.host = "mitmproxy.org"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from libmproxy import utils, script
|
||||
import glob
|
||||
from libmproxy.proxy import config
|
||||
import tservers
|
||||
|
||||
example_dir = utils.Data("libmproxy").path("../examples/")
|
||||
scripts = glob.glob("%s*.py" % example_dir)
|
||||
|
||||
tmaster = tservers.TestMaster(config.ProxyConfig())
|
||||
|
||||
for f in scripts:
|
||||
script.Script(f, tmaster) # Loads the script file.
|
Loading…
Reference in New Issue