From 9854379046a5464f4fd638785bafca87b91a495a Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 26 Mar 2015 18:17:30 +0100 Subject: [PATCH] web: backup flows on edit --- libmproxy/flow.py | 4 ++++ libmproxy/web/app.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 8343c1832..9aa2a179f 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -593,6 +593,10 @@ class State(object): def accept_all(self, master): self.flows.accept_all(master) + def backup(self, f): + f.backup() + self.update_flow(f) + def revert(self, f): f.revert() self.update_flow(f) diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py index 76160dc17..d95fb8ea0 100644 --- a/libmproxy/web/app.py +++ b/libmproxy/web/app.py @@ -119,6 +119,7 @@ class FlowHandler(RequestHandler): def put(self, flow_id): flow = self.flow + self.state.backup(flow) for a, b in self.json.iteritems(): if a == "request": @@ -130,6 +131,8 @@ class FlowHandler(RequestHandler): request.port = int(v) elif k == "httpversion": request.httpversion = tuple(int(x) for x in v) + elif k == "headers": + request.headers.load_state(v) else: print "Warning: Unknown update {}.{}: {}".format(a, k, v) @@ -142,6 +145,10 @@ class FlowHandler(RequestHandler): response.code = int(v) elif k == "httpversion": response.httpversion = tuple(int(x) for x in v) + elif k == "headers": + response.headers.load_state(v) + else: + print "Warning: Unknown update {}.{}: {}".format(a, k, v) else: print "Warning: Unknown update {}: {}".format(a, b) self.state.update_flow(flow)