aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/proxy.py4
-rw-r--r--test/test_proxy.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 1c4d4d71..88c62b25 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -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"],
diff --git a/test/test_proxy.py b/test/test_proxy.py
index ba9d9bfa..cb2528fd 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -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):