mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 10:26:23 +00:00
web: backup flows on edit
This commit is contained in:
parent
968c7021df
commit
9854379046
@ -593,6 +593,10 @@ class State(object):
|
|||||||
def accept_all(self, master):
|
def accept_all(self, master):
|
||||||
self.flows.accept_all(master)
|
self.flows.accept_all(master)
|
||||||
|
|
||||||
|
def backup(self, f):
|
||||||
|
f.backup()
|
||||||
|
self.update_flow(f)
|
||||||
|
|
||||||
def revert(self, f):
|
def revert(self, f):
|
||||||
f.revert()
|
f.revert()
|
||||||
self.update_flow(f)
|
self.update_flow(f)
|
||||||
|
@ -119,6 +119,7 @@ class FlowHandler(RequestHandler):
|
|||||||
|
|
||||||
def put(self, flow_id):
|
def put(self, flow_id):
|
||||||
flow = self.flow
|
flow = self.flow
|
||||||
|
self.state.backup(flow)
|
||||||
for a, b in self.json.iteritems():
|
for a, b in self.json.iteritems():
|
||||||
|
|
||||||
if a == "request":
|
if a == "request":
|
||||||
@ -130,6 +131,8 @@ class FlowHandler(RequestHandler):
|
|||||||
request.port = int(v)
|
request.port = int(v)
|
||||||
elif k == "httpversion":
|
elif k == "httpversion":
|
||||||
request.httpversion = tuple(int(x) for x in v)
|
request.httpversion = tuple(int(x) for x in v)
|
||||||
|
elif k == "headers":
|
||||||
|
request.headers.load_state(v)
|
||||||
else:
|
else:
|
||||||
print "Warning: Unknown update {}.{}: {}".format(a, k, v)
|
print "Warning: Unknown update {}.{}: {}".format(a, k, v)
|
||||||
|
|
||||||
@ -142,6 +145,10 @@ class FlowHandler(RequestHandler):
|
|||||||
response.code = int(v)
|
response.code = int(v)
|
||||||
elif k == "httpversion":
|
elif k == "httpversion":
|
||||||
response.httpversion = tuple(int(x) for x in v)
|
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:
|
else:
|
||||||
print "Warning: Unknown update {}: {}".format(a, b)
|
print "Warning: Unknown update {}: {}".format(a, b)
|
||||||
self.state.update_flow(flow)
|
self.state.update_flow(flow)
|
||||||
|
Loading…
Reference in New Issue
Block a user