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
def req(self): headers = Headers(header="qvalue") req = http.HTTPRequest("absolute", "GET", "http", "host", 80, "/path", (1, 1), headers, "content_request", None, None) f = http.HTTPFlow(tutils.tclient_conn(), None) f.request = req return f
def test_state(self): c = tutils.tclient_conn() assert ClientConnection._from_state(c._get_state()) == c c2 = tutils.tclient_conn() c2.address.address = (c2.address.host, 4242) assert not c == c2 c2.timestamp_start = 42 c._load_state(c2._get_state()) assert c.timestamp_start == 42 c3 = c.copy() assert c3 == c assert str(c)
def req(self): headers = odict.ODictCaseless() headers["header"] = ["qvalue"] req = http.HTTPRequest("absolute", "GET", "http", "host", 80, "/path", (1, 1), headers, "content_request", None, None) f = http.HTTPFlow(tutils.tclient_conn(), None) f.request = req return f
def req(self): headers = Headers(header="qvalue") req = http.HTTPRequest( "absolute", "GET", "http", "host", 80, "/path", b"HTTP/1.1", headers, "content_request", None, None ) f = http.HTTPFlow(tutils.tclient_conn(), None) f.request = req return f
def req(self): headers = flow.ODictCaseless() headers["header"] = ["qvalue"] req = http.HTTPRequest( "absolute", "GET", "http", "host", 80, "/path", (1, 1), headers, "content_request", None, None ) f = http.HTTPFlow(tutils.tclient_conn(), None) f.request = req return f