Add API to programmatically create new requests (#1534)

This commit is contained in:
Tyler St. Onge 2016-10-01 07:06:59 -04:00 committed by Thomas Kriechbaumer
parent 05e2e55eb8
commit ccbdcd684b
2 changed files with 13 additions and 0 deletions

View File

@ -187,6 +187,10 @@ class FlowMaster(controller.Master):
rt.join()
return rt
def new_request(self, method, scheme, host, port, path, block=False):
f = self.create_request(method, scheme, host, port, path)
return self.replay_request(f, block)
@controller.handler
def log(self, l):
self.add_log(l.msg, l.level)

View File

@ -463,6 +463,15 @@ class TestFlowMaster:
assert s.flow_count() == 2
assert s.index(f2) == 1
def test_new_request(self):
s = flow.State()
fm = flow.FlowMaster(
options.Options(),
DummyServer(ProxyConfig(options.Options())),
s
)
assert fm.new_request("GET", "http", "example.com", 80, "/")
def test_create_flow(self):
s = flow.State()
fm = flow.FlowMaster(None, None, s)