Serialize requestcount for ClientConnect objects.
This commit is contained in:
parent
b9737ed89e
commit
ab0e10e60f
|
@ -324,7 +324,7 @@ class Request(HTTPMsg):
|
||||||
|
|
||||||
Exposes the following attributes:
|
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
|
headers: ODictCaseless object
|
||||||
content: Content of the request, or None
|
content: Content of the request, or None
|
||||||
|
|
||||||
|
@ -760,15 +760,20 @@ class ClientConnect(controller.Msg):
|
||||||
return self._get_state() == other._get_state()
|
return self._get_state() == other._get_state()
|
||||||
|
|
||||||
def _load_state(self, state):
|
def _load_state(self, state):
|
||||||
self.address = state
|
self.requestcount = state["requestcount"]
|
||||||
|
|
||||||
def _get_state(self):
|
def _get_state(self):
|
||||||
return list(self.address) if self.address else None
|
return dict(
|
||||||
|
address = list(self.address),
|
||||||
|
requestcount = self.requestcount,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _from_state(klass, state):
|
def _from_state(klass, state):
|
||||||
if state:
|
if state:
|
||||||
return klass(state)
|
k = klass(state["address"])
|
||||||
|
k._load_state(state)
|
||||||
|
return k
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -923,8 +923,9 @@ class uClientConnect(libpry.AutoTree):
|
||||||
c2 = flow.ClientConnect(("a", 25))
|
c2 = flow.ClientConnect(("a", 25))
|
||||||
assert not c == c2
|
assert not c == c2
|
||||||
|
|
||||||
|
c2.requestcount = 99
|
||||||
c._load_state(c2._get_state())
|
c._load_state(c2._get_state())
|
||||||
assert c == c2
|
assert c.requestcount == 99
|
||||||
|
|
||||||
c3 = c.copy()
|
c3 = c.copy()
|
||||||
assert c3 == c
|
assert c3 == c
|
||||||
|
|
Loading…
Reference in New Issue