aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-04-03 22:37:24 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-04-03 22:37:24 +1200
commitab0e10e60f9d481ac0aa782c69bd02de9b7fbf0d (patch)
tree949b4353cc4b5b325ff07cb34d42a22db80ddafa
parentb9737ed89e32fd0f4d5ec842c64e2a1ccc5a9274 (diff)
downloadmitmproxy-ab0e10e60f9d481ac0aa782c69bd02de9b7fbf0d.tar.gz
mitmproxy-ab0e10e60f9d481ac0aa782c69bd02de9b7fbf0d.tar.bz2
mitmproxy-ab0e10e60f9d481ac0aa782c69bd02de9b7fbf0d.zip
Serialize requestcount for ClientConnect objects.
-rw-r--r--libmproxy/flow.py13
-rw-r--r--test/test_flow.py3
2 files changed, 11 insertions, 5 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index 76a8a1c7..6444fb7e 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -324,7 +324,7 @@ class Request(HTTPMsg):
Exposes the following attributes:
- client_conn: ClientConnection object, or None if this is a replay.
+ client_conn: ClientConnect object, or None if this is a replay.
headers: ODictCaseless object
content: Content of the request, or None
@@ -760,15 +760,20 @@ class ClientConnect(controller.Msg):
return self._get_state() == other._get_state()
def _load_state(self, state):
- self.address = state
+ self.requestcount = state["requestcount"]
def _get_state(self):
- return list(self.address) if self.address else None
+ return dict(
+ address = list(self.address),
+ requestcount = self.requestcount,
+ )
@classmethod
def _from_state(klass, state):
if state:
- return klass(state)
+ k = klass(state["address"])
+ k._load_state(state)
+ return k
else:
return None
diff --git a/test/test_flow.py b/test/test_flow.py
index 60a4fc04..a7ab7cc2 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -923,8 +923,9 @@ class uClientConnect(libpry.AutoTree):
c2 = flow.ClientConnect(("a", 25))
assert not c == c2
+ c2.requestcount = 99
c._load_state(c2._get_state())
- assert c == c2
+ assert c.requestcount == 99
c3 = c.copy()
assert c3 == c