diff --git a/libmproxy/dump.py b/libmproxy/dump.py index fe81eda19..50d4dc4b2 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -31,7 +31,10 @@ def str_response(resp): def str_request(req): - return "%s %s"%(req.method, req.url()) + r = "%s %s"%(req.method, req.url()) + if req.stickycookie: + r = "[stickycookie] " + r + return r class DumpMaster(flow.FlowMaster): diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 8e4db57d6..a82b978c1 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -126,6 +126,7 @@ class StickyCookieState: ] if all(match): l = f.request.headers.setdefault("cookie", []) + f.request.stickycookie = True l.append(self.jar[i].output(header="").strip()) diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 286ef3fb2..2a2904e50 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -136,6 +136,9 @@ class Request(controller.Msg): self.close = False controller.Msg.__init__(self) + # Have this request's cookies been modified by sticky cookies? + self.stickycookie = False + def set_replay(self): self.client_conn = None diff --git a/test/test_dump.py b/test/test_dump.py index 1f6b7acc9..cfa690b17 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -10,6 +10,10 @@ class uStrFuncs(libpry.AutoTree): t.set_replay() dump.str_response(t) + t = utils.treq() + t.stickycookie = True + assert "stickycookie" in dump.str_request(t) + class uDumpMaster(libpry.AutoTree): def _cycle(self, m, content):