diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-11-06 15:24:54 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-11-06 15:24:54 +0100 |
commit | e6e28c2ac37652ad21cf7a4e351c419fffa10f4b (patch) | |
tree | e507f0d2469750612a9c6729ca2ae899bbe415c2 | |
parent | 4cb96dedd0143cf9b6278d3622457e1e485b3090 (diff) | |
download | mitmproxy-e6e28c2ac37652ad21cf7a4e351c419fffa10f4b.tar.gz mitmproxy-e6e28c2ac37652ad21cf7a4e351c419fffa10f4b.tar.bz2 mitmproxy-e6e28c2ac37652ad21cf7a4e351c419fffa10f4b.zip |
fix revert of duplicated flows
-rw-r--r-- | mitmproxy/flow.py | 1 | ||||
-rw-r--r-- | mitmproxy/http.py | 1 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 11 |
3 files changed, 13 insertions, 0 deletions
diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py index 294aba26..dc778404 100644 --- a/mitmproxy/flow.py +++ b/mitmproxy/flow.py @@ -99,6 +99,7 @@ class Flow(stateobject.StateObject): return d def set_state(self, state): + state = state.copy() state.pop("version") if "backup" in state: self._backup = state.pop("backup") diff --git a/mitmproxy/http.py b/mitmproxy/http.py index c09778fe..7762647b 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -56,6 +56,7 @@ class HTTPRequest(http.Request): return state def set_state(self, state): + state = state.copy() self.is_replay = state.pop("is_replay") super().set_state(state) diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 7f9d577b..fcc766b5 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -84,6 +84,17 @@ class TestSerialize: with pytest.raises(Exception, match="version"): list(r.stream()) + def test_copy(self): + """ + _backup may be shared across instances. That should not raise errors. + """ + f = tflow.tflow() + f.backup() + f.request.path = "/foo" + f2 = f.copy() + f2.revert() + f.revert() + class TestFlowMaster: def test_load_flow_reverse(self): |