diff options
| author | Maximilian Hils <git@maximilianhils.com> | 2014-12-23 20:33:42 +0100 |
|---|---|---|
| committer | Maximilian Hils <git@maximilianhils.com> | 2014-12-23 20:33:42 +0100 |
| commit | 2861d99de4d329bcba0a3c2193523398a22673c0 (patch) | |
| tree | 0aa1a2aae666c2909285a6fd5049f2ef7d6d8ebc /libmproxy/web/__init__.py | |
| parent | 459772a8ef79ac0adeaeba56577972e86074265e (diff) | |
| download | mitmproxy-2861d99de4d329bcba0a3c2193523398a22673c0.tar.gz mitmproxy-2861d99de4d329bcba0a3c2193523398a22673c0.tar.bz2 mitmproxy-2861d99de4d329bcba0a3c2193523398a22673c0.zip | |
web: intercept feature
Diffstat (limited to 'libmproxy/web/__init__.py')
| -rw-r--r-- | libmproxy/web/__init__.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libmproxy/web/__init__.py b/libmproxy/web/__init__.py index 4c36c009..ec3576db 100644 --- a/libmproxy/web/__init__.py +++ b/libmproxy/web/__init__.py @@ -123,7 +123,7 @@ class WebMaster(flow.FlowMaster): def __init__(self, server, options): self.options = options super(WebMaster, self).__init__(server, WebState()) - self.app = app.Application(self.state, self.options.wdebug) + self.app = app.Application(self, self.options.wdebug) def tick(self): flow.FlowMaster.tick(self, self.masterq, timeout=0) @@ -144,17 +144,23 @@ class WebMaster(flow.FlowMaster): except (Stop, KeyboardInterrupt): self.shutdown() + def _process_flow(self, f): + if self.state.intercept and self.state.intercept(f) and not f.request.is_replay: + f.intercept(self) + else: + f.reply() + def handle_request(self, f): super(WebMaster, self).handle_request(f) - if f: - f.reply() - return f + self._process_flow(f) def handle_response(self, f): super(WebMaster, self).handle_response(f) - if f: - f.reply() - return f + self._process_flow(f) + + def handle_error(self, f): + super(WebMaster, self).handle_error(f) + self._process_flow(f) def add_event(self, e, level="info"): super(WebMaster, self).add_event(e, level) |
