def test_getset_state(self): h = utils.Headers() h["test"] = ["test"] c = proxy.ClientConnect(("addr", 2222)) r = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") req = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") resp = proxy.Response(req, 200, "msg", h.copy(), "content") state = resp.get_state() assert proxy.Response.from_state(req, state) == resp resp2 = proxy.Response(req, 220, "foo", h.copy(), "test") assert not resp == resp2 resp.load_state(resp2.get_state()) assert resp == resp2
def treq(conn=None): if not conn: conn = proxy.ClientConnect(("address", 22)) headers = utils.Headers() headers["header"] = ["qvalue"] return proxy.Request(conn, "host", 80, "http", "GET", "/path", headers, "content")
def test_anticache(self): h = utils.Headers() r = proxy.Request(None, "host", 22, "https", "GET", "/", h, "content") h["if-modified-since"] = ["test"] h["if-none-match"] = ["test"] r.anticache() assert not "if-modified-since" in r.headers assert not "if-none-match" in r.headers
def test_simple(self): h = utils.Headers() h["test"] = ["test"] c = proxy.ClientConnect(("addr", 2222)) req = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") resp = proxy.Response(req, 200, "msg", h.copy(), "content") assert resp.assemble() resp2 = resp.copy() assert resp2 == resp
def test_getset_state(self): h = utils.Headers() h["test"] = ["test"] c = proxy.ClientConnect(("addr", 2222)) r = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") state = r.get_state() assert proxy.Request.from_state(state) == r r.client_conn = None state = r.get_state() assert proxy.Request.from_state(state) == r r2 = proxy.Request(c, "testing", 20, "http", "PUT", "/foo", h, "test") assert not r == r2 r.load_state(r2.get_state()) assert r == r2 r2.client_conn = None r.load_state(r2.get_state()) assert not r.client_conn
def test_simple(self): h = utils.Headers() h["test"] = ["test"] c = proxy.ClientConnect(("addr", 2222)) r = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") u = r.url() assert r.set_url(u) assert not r.set_url("") assert r.url() == u assert r.assemble() r2 = r.copy() assert r == r2
def req(self): conn = proxy.ClientConnect(("one", 2222)) headers = utils.Headers() headers["header"] = ["qvalue"] return proxy.Request(conn, "host", 80, "http", "GET", "/path", headers, "content_request")