mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-23 03:49:21 +08:00
Fix serialization when a Request has no associated client connection.
This commit is contained in:
@@ -150,7 +150,7 @@ class Request(controller.Msg):
|
||||
|
||||
def get_state(self):
|
||||
return dict(
|
||||
client_conn = self.client_conn.get_state(),
|
||||
client_conn = self.client_conn.get_state() if self.client_conn else None,
|
||||
host = self.host,
|
||||
port = self.port,
|
||||
scheme = self.scheme,
|
||||
@@ -164,7 +164,7 @@ class Request(controller.Msg):
|
||||
@classmethod
|
||||
def from_state(klass, state):
|
||||
return klass(
|
||||
ClientConnect.from_state(state["client_conn"]),
|
||||
ClientConnect.from_state(state["client_conn"]) if state["client_conn"] else None,
|
||||
state["host"],
|
||||
state["port"],
|
||||
state["scheme"],
|
||||
|
||||
@@ -230,6 +230,10 @@ class uRequest(libpry.AutoTree):
|
||||
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
|
||||
|
||||
|
||||
class uResponse(libpry.AutoTree):
|
||||
def test_simple(self):
|
||||
|
||||
Reference in New Issue
Block a user