diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-11-26 04:18:21 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-11-26 04:18:21 +0100 |
commit | ed8249023fb7c0d429b9278c63b51ac071700987 (patch) | |
tree | 8bd83354e7484f15029ec678744234bd32e9906d /libmproxy/web/__init__.py | |
parent | 47a78e3c729f4ddb7971b72bfae30140562f4dd6 (diff) | |
download | mitmproxy-ed8249023fb7c0d429b9278c63b51ac071700987.tar.gz mitmproxy-ed8249023fb7c0d429b9278c63b51ac071700987.tar.bz2 mitmproxy-ed8249023fb7c0d429b9278c63b51ac071700987.zip |
introduce revised views, port over changes from multiple_views branch
Diffstat (limited to 'libmproxy/web/__init__.py')
-rw-r--r-- | libmproxy/web/__init__.py | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/libmproxy/web/__init__.py b/libmproxy/web/__init__.py index 69971436..f762466a 100644 --- a/libmproxy/web/__init__.py +++ b/libmproxy/web/__init__.py @@ -9,9 +9,32 @@ class Stop(Exception): pass +class WebFlowView(flow.FlowView): + def __init__(self, store): + super(WebFlowView, self).__init__(store, None) + + def _add(self, f): + super(WebFlowView, self)._add(f) + app.FlowUpdates.broadcast("add", f.get_state(short=True)) + + def _update(self, f): + super(WebFlowView, self)._update(f) + app.FlowUpdates.broadcast("update", f.get_state(short=True)) + + def _remove(self, f): + super(WebFlowView, self)._remove(f) + app.FlowUpdates.broadcast("remove", f.get_state(short=True)) + + def _recalculate(self, flows): + super(WebFlowView, self)._recalculate(flows) + app.FlowUpdates.broadcast("recalculate", None) + + class WebState(flow.State): def __init__(self): - flow.State.__init__(self) + super(WebState, self).__init__() + self.view._close() + self.view = WebFlowView(self.flows) class Options(object): @@ -58,8 +81,8 @@ class Options(object): class WebMaster(flow.FlowMaster): def __init__(self, server, options): self.options = options - self.app = app.Application(self.options.wdebug) super(WebMaster, self).__init__(server, WebState()) + self.app = app.Application(self.state, self.options.wdebug) self.last_log_id = 0 @@ -83,24 +106,17 @@ class WebMaster(flow.FlowMaster): self.shutdown() def handle_request(self, f): - app.ClientConnection.broadcast("add_flow", f.get_state(True)) - flow.FlowMaster.handle_request(self, f) + super(WebMaster, self).handle_request(f) if f: f.reply() return f def handle_response(self, f): - app.ClientConnection.broadcast("update_flow", f.get_state(True)) - flow.FlowMaster.handle_response(self, f) + super(WebMaster, self).handle_response(f) if f: f.reply() return f - def handle_error(self, f): - app.ClientConnection.broadcast("update_flow", f.get_state(True)) - flow.FlowMaster.handle_error(self, f) - return f - def handle_log(self, l): self.last_log_id += 1 app.ClientConnection.broadcast( |