本文整理汇总了Python中tutils.tresp函数的典型用法代码示例。如果您正苦于以下问题:Python tresp函数的具体用法?Python tresp怎么用?Python tresp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tresp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_all
def test_all(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
fm.anticache = True
fm.anticomp = True
req = tutils.treq()
fm.handle_clientconnect(req.flow.client_conn)
f = fm.handle_request(req)
assert s.flow_count() == 1
resp = tutils.tresp(req)
fm.handle_response(resp)
assert s.flow_count() == 1
rx = tutils.tresp()
rx.flow = None
assert not fm.handle_response(rx)
fm.handle_clientdisconnect(req.flow.client_conn)
f.error = Error("msg")
f.error.reply = controller.DummyReply()
fm.handle_error(f.error)
fm.load_script(tutils.test_data.path("scripts/a.py"))
fm.shutdown()
开发者ID:Jamie-Landeg-Jones,项目名称:mitmproxy,代码行数:27,代码来源:test_flow.py
示例2: test_decodeencode
def test_decodeencode(self):
r = tutils.tresp()
r.headers["content-encoding"] = ["identity"]
r.content = "falafel"
assert r.decode()
assert not r.headers["content-encoding"]
assert r.content == "falafel"
r = tutils.tresp()
r.headers["content-encoding"] = ["identity"]
r.content = "falafel"
r.encode("identity")
assert r.headers["content-encoding"] == ["identity"]
assert r.content == "falafel"
r = tutils.tresp()
r.headers["content-encoding"] = ["identity"]
r.content = "falafel"
r.encode("gzip")
assert r.headers["content-encoding"] == ["gzip"]
assert r.content != "falafel"
assert r.decode()
assert not r.headers["content-encoding"]
assert r.content == "falafel"
r.headers["content-encoding"] = ["gzip"]
assert not r.decode()
assert r.content == "falafel"
开发者ID:AmineCherrai,项目名称:mitmproxy,代码行数:28,代码来源:test_flow.py
示例3: test_flow
def test_flow(self):
"""
normal flow:
connect -> request -> response
"""
bc = tutils.tclient_conn()
c = flow.State()
req = tutils.treq(bc)
f = c.add_request(req)
assert f
assert c.flow_count() == 1
assert c.active_flow_count() == 1
newreq = tutils.treq()
assert c.add_request(newreq)
assert c.active_flow_count() == 2
resp = tutils.tresp(req)
assert c.add_response(resp)
assert c.flow_count() == 2
assert c.active_flow_count() == 1
unseen_resp = tutils.tresp()
unseen_resp.flow = None
assert not c.add_response(unseen_resp)
assert c.active_flow_count() == 1
resp = tutils.tresp(newreq)
assert c.add_response(resp)
assert c.active_flow_count() == 0
开发者ID:Jamie-Landeg-Jones,项目名称:mitmproxy,代码行数:32,代码来源:test_flow.py
示例4: test_all
def test_all(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
fm.anticache = True
fm.anticomp = True
req = tutils.treq()
fm.handle_clientconnect(req.client_conn)
f = fm.handle_request(req)
assert s.flow_count() == 1
resp = tutils.tresp(req)
fm.handle_response(resp)
assert s.flow_count() == 1
rx = tutils.tresp()
assert not fm.handle_response(rx)
dc = flow.ClientDisconnect(req.client_conn)
req.client_conn.requestcount = 1
fm.handle_clientdisconnect(dc)
err = flow.Error(f.request, "msg")
fm.handle_error(err)
fm.load_script(tutils.test_data.path("scripts/a.py"))
fm.shutdown()
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:27,代码来源:test_flow.py
示例5: test_flow
def test_flow(self):
"""
normal flow:
connect -> request -> response
"""
bc = flow.ClientConnect(("address", 22))
c = flow.State()
req = tutils.treq(bc)
f = c.add_request(req)
assert f
assert c.flow_count() == 1
assert c._flow_map.get(req)
assert c.active_flow_count() == 1
newreq = tutils.treq()
assert c.add_request(newreq)
assert c._flow_map.get(newreq)
assert c.active_flow_count() == 2
resp = tutils.tresp(req)
assert c.add_response(resp)
assert c.flow_count() == 2
assert c._flow_map.get(resp.request)
assert c.active_flow_count() == 1
unseen_resp = tutils.tresp()
assert not c.add_response(unseen_resp)
assert not c._flow_map.get(unseen_resp.request)
assert c.active_flow_count() == 1
resp = tutils.tresp(newreq)
assert c.add_response(resp)
assert c.active_flow_count() == 0
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:35,代码来源:test_flow.py
示例6: test_flow
def test_flow(self):
"""
normal flow:
connect -> request -> response
"""
c = flow.State()
f = tutils.tflow()
c.add_request(f)
assert f
assert c.flow_count() == 1
assert c.active_flow_count() == 1
newf = tutils.tflow()
assert c.add_request(newf)
assert c.active_flow_count() == 2
f.response = tutils.tresp()
assert c.add_response(f)
assert c.flow_count() == 2
assert c.active_flow_count() == 1
_ = tutils.tresp()
assert not c.add_response(None)
assert c.active_flow_count() == 1
newf.response = tutils.tresp()
assert c.add_response(newf)
assert c.active_flow_count() == 0
开发者ID:AmineCherrai,项目名称:mitmproxy,代码行数:29,代码来源:test_flow.py
示例7: test_script
def test_script(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
assert not fm.load_script(tutils.test_data.path("scripts/all.py"))
req = tutils.treq()
fm.handle_clientconnect(req.flow.client_conn)
assert fm.scripts[0].ns["log"][-1] == "clientconnect"
sc = ServerConnection((req.get_host(), req.get_port()), None)
sc.reply = controller.DummyReply()
fm.handle_serverconnection(sc)
assert fm.scripts[0].ns["log"][-1] == "serverconnect"
f = fm.handle_request(req)
assert fm.scripts[0].ns["log"][-1] == "request"
resp = tutils.tresp(req)
fm.handle_response(resp)
assert fm.scripts[0].ns["log"][-1] == "response"
#load second script
assert not fm.load_script(tutils.test_data.path("scripts/all.py"))
assert len(fm.scripts) == 2
fm.handle_clientdisconnect(sc)
assert fm.scripts[0].ns["log"][-1] == "clientdisconnect"
assert fm.scripts[1].ns["log"][-1] == "clientdisconnect"
#unload first script
fm.unload_scripts()
assert len(fm.scripts) == 0
assert not fm.load_script(tutils.test_data.path("scripts/all.py"))
err = tutils.terr()
err.reply = controller.DummyReply()
fm.handle_error(err)
assert fm.scripts[0].ns["log"][-1] == "error"
开发者ID:Jamie-Landeg-Jones,项目名称:mitmproxy,代码行数:33,代码来源:test_flow.py
示例8: _flowfile
def _flowfile(self, path):
f = open(path, "wb")
fw = flow.FlowWriter(f)
t = tutils.tflow_full()
t.response = tutils.tresp(t.request)
fw.add(t)
f.close()
开发者ID:B-Rich,项目名称:mitmproxy,代码行数:7,代码来源:test_dump.py
示例9: test_set_limit
def test_set_limit(self):
c = flow.State()
req = tutils.treq()
c.clientconnect(req.client_conn)
assert len(c.view) == 0
f = c.add_request(req)
assert len(c.view) == 1
c.set_limit("~s")
assert len(c.view) == 0
resp = tutils.tresp(req)
c.add_response(resp)
assert len(c.view) == 1
c.set_limit(None)
assert len(c.view) == 1
req = tutils.treq()
c.clientconnect(req.client_conn)
c.add_request(req)
assert len(c.view) == 2
c.set_limit("~q")
assert len(c.view) == 1
c.set_limit("~s")
assert len(c.view) == 1
assert "Invalid" in c.set_limit("~")
开发者ID:xuzhe,项目名称:mitmproxy,代码行数:28,代码来源:test_flow.py
示例10: test_run_script
def test_run_script(self):
f = tutils.tflow()
f.response = tutils.tresp()
f.request = f.response.request
se = f.run_script("scripts/a")
assert "DEBUG" == se.strip()
assert f.request.host == "TESTOK"
开发者ID:xuzhe,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py
示例11: test_server_playback
def test_server_playback(self):
controller.should_exit = False
s = flow.State()
f = tutils.tflow()
f.response = tutils.tresp(f.request)
pb = [f]
fm = flow.FlowMaster(None, s)
fm.refresh_server_playback = True
assert not fm.do_server_playback(tutils.tflow())
fm.start_server_playback(pb, False, [], False, False)
assert fm.do_server_playback(tutils.tflow())
fm.start_server_playback(pb, False, [], True, False)
r = tutils.tflow()
r.request.content = "gibble"
assert not fm.do_server_playback(r)
assert fm.do_server_playback(tutils.tflow())
fm.start_server_playback(pb, False, [], True, False)
q = Queue.Queue()
fm.tick(q)
assert controller.should_exit
fm.stop_server_playback()
assert not fm.server_playback
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:28,代码来源:test_flow.py
示例12: test_get_cert
def test_get_cert(self):
req = tutils.treq()
resp = flow.Response(req, 200, "msg", flow.ODictCaseless(), "content", file("data/dercert").read())
assert resp.get_cert()
resp = tutils.tresp()
assert not resp.get_cert()
开发者ID:rjmolesa,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py
示例13: test_script
def test_script(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
assert not fm.load_script([tutils.test_data.path("scripts/all.py")])
req = tutils.treq()
fm.handle_clientconnect(req.client_conn)
assert fm.scripts[0].ns["log"][-1] == "clientconnect"
f = fm.handle_request(req)
assert fm.scripts[0].ns["log"][-1] == "request"
resp = tutils.tresp(req)
fm.handle_response(resp)
assert fm.scripts[0].ns["log"][-1] == "response"
#load second script
assert not fm.load_script([tutils.test_data.path("scripts/all.py")])
assert len(fm.scripts) == 2
dc = flow.ClientDisconnect(req.client_conn)
dc.reply = controller.DummyReply()
fm.handle_clientdisconnect(dc)
assert fm.scripts[0].ns["log"][-1] == "clientdisconnect"
assert fm.scripts[1].ns["log"][-1] == "clientdisconnect"
#unload first script
fm.unload_script(fm.scripts[0])
assert len(fm.scripts) == 1
err = flow.Error(f.request, "msg")
err.reply = controller.DummyReply()
fm.handle_error(err)
assert fm.scripts[0].ns["log"][-1] == "error"
开发者ID:billinghamj,项目名称:mitmproxy,代码行数:27,代码来源:test_flow.py
示例14: test_replay
def test_replay(self):
cs = StringIO()
o = dump.Options(server_replay="nonexistent", kill=True)
libpry.raises(dump.DumpError, dump.DumpMaster, None, o, None, outfile=cs)
t = self.tmpdir()
p = os.path.join(t, "rep")
f = open(p, "w")
fw = flow.FlowWriter(f)
t = tutils.tflow_full()
t.response = tutils.tresp(t.request)
fw.add(t)
f.close()
o = dump.Options(server_replay=p, kill=True)
m = dump.DumpMaster(None, o, None, outfile=cs)
self._cycle(m, "content")
self._cycle(m, "content")
o = dump.Options(server_replay=p, kill=False)
m = dump.DumpMaster(None, o, None, outfile=cs)
self._cycle(m, "nonexistent")
o = dump.Options(client_replay=p, kill=False)
m = dump.DumpMaster(None, o, None, outfile=cs)
开发者ID:celord,项目名称:mitmproxy,代码行数:27,代码来源:test_dump.py
示例15: test_set_limit
def test_set_limit(self):
c = flow.State()
req = tutils.treq()
assert len(c.view) == 0
c.add_request(req)
assert len(c.view) == 1
c.set_limit("~s")
assert c.limit_txt == "~s"
assert len(c.view) == 0
resp = tutils.tresp(req)
c.add_response(resp)
assert len(c.view) == 1
c.set_limit(None)
assert len(c.view) == 1
req = tutils.treq()
c.add_request(req)
assert len(c.view) == 2
c.set_limit("~q")
assert len(c.view) == 1
c.set_limit("~s")
assert len(c.view) == 1
assert "Invalid" in c.set_limit("~")
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:27,代码来源:test_flow.py
示例16: test_set_limit
def test_set_limit(self):
c = flow.State()
f = tutils.tflow()
assert len(c.view) == 0
c.add_request(f)
assert len(c.view) == 1
c.set_limit("~s")
assert c.limit_txt == "~s"
assert len(c.view) == 0
f.response = tutils.tresp()
c.add_response(f)
assert len(c.view) == 1
c.set_limit(None)
assert len(c.view) == 1
f = tutils.tflow()
c.add_request(f)
assert len(c.view) == 2
c.set_limit("~q")
assert len(c.view) == 1
c.set_limit("~s")
assert len(c.view) == 1
assert "Invalid" in c.set_limit("~")
开发者ID:AmineCherrai,项目名称:mitmproxy,代码行数:27,代码来源:test_flow.py
示例17: test_replace
def test_replace(self):
r = tutils.tresp()
r.headers["Foo"] = ["fOo"]
r.content = "afoob"
assert r.replace("foo(?i)", "boo") == 3
assert not "foo" in r.content
assert r.headers["boo"] == ["boo"]
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py
示例18: test_simple
def test_simple(self):
f = tutils.tflow()
foc = ('focus', '>>')
assert foc not in console.format_flow(f, False)
assert foc in console.format_flow(f, True)
assert foc not in console.format_flow(f, False, True)
assert foc in console.format_flow(f, True, True)
f.response = tutils.tresp()
f.request = f.response.request
f.backup()
f.request._set_replay()
f.response._set_replay()
assert ('method', '[replay]') in console.format_flow(f, True)
assert ('method', '[replay]') in console.format_flow(f, True, True)
f.response.code = 404
assert ('error', '404') in console.format_flow(f, True, True)
f.response.headers["content-type"] = ["text/html"]
assert ('text', ' text/html') in console.format_flow(f, True, True)
f.response =None
f.error = flow.Error(f.request, "error")
assert ('error', 'error') in console.format_flow(f, True, True)
开发者ID:0m15,项目名称:mitmproxy,代码行数:26,代码来源:test_console.py
示例19: test_run_script_err
def test_run_script_err(self):
f = tutils.tflow()
f.response = tutils.tresp()
f.request = f.response.request
libpry.raises("returned error", f.run_script,"scripts/err_return")
libpry.raises("invalid response", f.run_script,"scripts/err_data")
libpry.raises("no such file", f.run_script,"nonexistent")
libpry.raises("permission denied", f.run_script,"scripts/nonexecutable")
开发者ID:xuzhe,项目名称:mitmproxy,代码行数:8,代码来源:test_flow.py
示例20: test_set_cookies
def test_set_cookies(self):
resp = tutils.tresp()
v = resp.get_cookies()
v.add("foo", ["bar", odict.ODictCaseless()])
resp.set_cookies(v)
v = resp.get_cookies()
assert len(v) == 1
assert v["foo"] == [["bar", odict.ODictCaseless()]]
开发者ID:MrTillis,项目名称:mitmproxy,代码行数:9,代码来源:test_protocol_http.py
注:本文中的tutils.tresp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论