当前位置: 首页>>代码示例>>Python>>正文


Python tutils.tflow_full函数代码示例

本文整理汇总了Python中tutils.tflow_full函数的典型用法代码示例。如果您正苦于以下问题:Python tflow_full函数的具体用法?Python tflow_full怎么用?Python tflow_full使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tflow_full函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_stream

    def test_stream(self):
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")

            def r():
                r = flow.FlowReader(open(p))
                return list(r.stream())

            s = flow.State()
            fm = flow.FlowMaster(None, s)
            tf = tutils.tflow_full()

            fm.start_stream(file(p, "ab"), None)
            fm.handle_request(tf.request)
            fm.handle_response(tf.response)
            fm.stop_stream()

            assert r()[0].response

            tf = tutils.tflow_full()
            fm.start_stream(file(p, "ab"), None)
            fm.handle_request(tf.request)
            fm.shutdown()

            assert not r()[1].response
开发者ID:Rafiot,项目名称:mitmproxy,代码行数:25,代码来源:test_flow.py

示例2: test_handle_response

    def test_handle_response(self):
        s = flow.StickyAuthState(filt.parse(".*"))
        f = tutils.tflow_full()
        f.request.headers["authorization"] = ["foo"]
        s.handle_request(f)
        assert "host" in s.hosts

        f = tutils.tflow_full()
        s.handle_request(f)
        assert f.request.headers["authorization"] == ["foo"]
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:10,代码来源:test_flow.py

示例3: test_load_with_nopop

    def test_load_with_nopop(self):
        r = tutils.tflow_full()
        r.request.headers["key"] = ["one"]

        r2 = tutils.tflow_full()
        r2.request.headers["key"] = ["two"]

        s = flow.ServerPlaybackState(None, [r, r2], False, True)

        assert s.count() == 2
        s.next_flow(r)
        assert s.count() == 2
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:12,代码来源:test_flow.py

示例4: test_headers

    def test_headers(self):
        s = flow.ServerPlaybackState(["foo"], [], False, False)
        r = tutils.tflow_full()
        r.request.headers["foo"] = ["bar"]
        r2 = tutils.tflow_full()
        assert not s._hash(r) == s._hash(r2)
        r2.request.headers["foo"] = ["bar"]
        assert s._hash(r) == s._hash(r2)
        r2.request.headers["oink"] = ["bar"]
        assert s._hash(r) == s._hash(r2)

        r = tutils.tflow_full()
        r2 = tutils.tflow_full()
        assert s._hash(r) == s._hash(r2)
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:14,代码来源:test_flow.py

示例5: test_client_playback

    def test_client_playback(self):
        s = flow.State()

        f = tutils.tflow_full()
        pb = [tutils.tflow_full(), f]
        fm = flow.FlowMaster(None, s)
        assert not fm.start_server_playback(pb, False, [], False, False)
        assert not fm.start_client_playback(pb, False)

        q = Queue.Queue()
        assert not fm.state.flow_count()
        fm.tick(q)
        assert fm.state.flow_count()

        fm.handle_error(flow.Error(f.request, "error"))
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:15,代码来源:test_flow.py

示例6: test_copy

 def test_copy(self):
     f = tutils.tflow_full()
     f2 = f.copy()
     assert not f is f2
     assert not f.request is f2.request
     assert f.request.headers == f2.request.headers
     assert not f.request.headers is f2.request.headers
开发者ID:SamGimbel,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py

示例7: 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

示例8: test_filter

    def test_filter(self):
        sio = StringIO()
        fl = filt.parse("~c 200")
        w = flow.FilteredFlowWriter(sio, fl)

        f = tutils.tflow_full()
        f.response.code = 200
        w.add(f)

        f = tutils.tflow_full()
        f.response.code = 201
        w.add(f)

        sio.seek(0)
        r = flow.FlowReader(sio)
        assert len(list(r.stream()))
开发者ID:evidon,项目名称:mitmproxy,代码行数:16,代码来源:test_flow.py

示例9: _response

 def _response(self, cookie, host):
     s = flow.StickyCookieState(filt.parse(".*"))
     f = tutils.tflow_full()
     f.request.host = host
     f.response.headers["Set-Cookie"] = [cookie]
     s.handle_response(f)
     return s, f
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py

示例10: _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

示例11: _response

 def _response(self, cookie, host):
     s = flow.StickyCookieState(filt.parse(".*"))
     f = tutils.tflow_full()
     f.server_conn.address = tcp.Address((host, 80))
     f.response.headers["Set-Cookie"] = [cookie]
     s.handle_response(f)
     return s, f
开发者ID:Jamie-Landeg-Jones,项目名称:mitmproxy,代码行数:7,代码来源:test_flow.py

示例12: test_client_playback

    def test_client_playback(self):
        s = flow.State()

        f = tutils.tflow_full()
        pb = [tutils.tflow_full(), f]
        fm = flow.FlowMaster(None, s)
        assert not fm.start_server_playback(pb, False, [], False, False)
        assert not fm.start_client_playback(pb, False)

        q = Queue.Queue()
        assert not fm.state.flow_count()
        fm.tick(q)
        assert fm.state.flow_count()

        f.error = Error("error")
        f.error.reply = controller.DummyReply()
        fm.handle_error(f.error)
开发者ID:Jamie-Landeg-Jones,项目名称:mitmproxy,代码行数:17,代码来源:test_flow.py

示例13: test_replay

    def test_replay(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        f = tutils.tflow_full()
        f.request.content = flow.CONTENT_MISSING
        assert "missing" in fm.replay_request(f)

        f.intercepting = True
        assert "intercepting" in fm.replay_request(f)
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:9,代码来源:test_flow.py

示例14: test_duplicate_flow

 def test_duplicate_flow(self):
     s = flow.State()
     fm = flow.FlowMaster(None, s)
     f = tutils.tflow_full()
     fm.load_flow(f)
     assert s.flow_count() == 1
     f2 = fm.duplicate_flow(f)
     assert f2.response
     assert s.flow_count() == 2
     assert s.index(f2)
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:10,代码来源:test_flow.py

示例15: test_stickyauth

    def test_stickyauth(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        assert "Invalid" in fm.set_stickyauth("~h")
        fm.set_stickyauth(".*")
        assert fm.stickyauth_state
        fm.set_stickyauth(None)
        assert not fm.stickyauth_state

        fm.set_stickyauth(".*")
        tf = tutils.tflow_full()
        tf.request.headers["authorization"] = ["foo"]
        fm.handle_request(tf.request)

        f = tutils.tflow_full()
        assert fm.stickyauth_state.hosts
        assert not "authorization" in f.request.headers
        fm.handle_request(f.request)
        assert f.request.headers["authorization"] == ["foo"]
开发者ID:alxsoares,项目名称:mitmproxy,代码行数:19,代码来源:test_flow.py


注:本文中的tutils.tflow_full函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。