diff options
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/console.py | 5 | ||||
-rw-r--r-- | libmproxy/flow.py | 25 |
2 files changed, 23 insertions, 7 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py index 63dbf4f0..9e065e4d 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -1127,11 +1127,10 @@ class ConsoleMaster(flow.FlowMaster): try: f = file(path, "r") fr = flow.FlowReader(f) - data = list(fr.stream()) - f.close() except IOError, v: return v.strerror - self.state.load_flows(data) + flow.FlowMaster.load_flows(self, fr) + f.close() if self.conn_list_view: self.sync_list_view() self.focus_current() diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 387c49f0..b53794c9 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -542,6 +542,20 @@ class FlowMaster(controller.Master): controller.Master.tick(self, q) + def load_flows(self, fr): + """ + Load flows from a FlowReader object. + """ + for i in fr.stream(): + if i.request: + f = self.state.add_request(i.request) + self.process_new_request(f) + if i.response: + f = self.state.add_response(i.response) + self.process_new_response(f) + if i.error: + f = self.state.add_error(i.error) + def process_new_request(self, f): if self.stickycookie_state: self.stickycookie_state.handle_request(f) @@ -560,6 +574,12 @@ class FlowMaster(controller.Master): else: f.request.ack() + def process_new_response(self, f): + if self.stickycookie_state: + self.stickycookie_state.handle_response(f) + if "response" in self.scripts: + self._runscript(f, self.scripts["response"]) + def replay_request(self, f): """ Returns None if successful, or error message if not. @@ -605,10 +625,7 @@ class FlowMaster(controller.Master): self.client_playback.clear(f) if not f: r.ack() - if self.stickycookie_state: - self.stickycookie_state.handle_response(f) - if "response" in self.scripts: - self._runscript(f, self.scripts["response"]) + self.process_new_response(f) return f |