diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-05-29 20:03:40 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2016-05-29 20:03:40 +1200 |
commit | f3bee6f24539005e0916e786805e1655bb7f80f8 (patch) | |
tree | efa23c05738aae1aeb396b10fd012151d66d555c /examples | |
parent | 85aa5da6e3b7d811d316ed692ecd40e5442abe02 (diff) | |
parent | 0176f50e4f4994be4b19be212f3a3db053a18d0c (diff) | |
download | mitmproxy-f3bee6f24539005e0916e786805e1655bb7f80f8.tar.gz mitmproxy-f3bee6f24539005e0916e786805e1655bb7f80f8.tar.bz2 mitmproxy-f3bee6f24539005e0916e786805e1655bb7f80f8.zip |
Merge pull request #1172 from cortesi/solidcore
First steps to solidifying the core
Diffstat (limited to 'examples')
-rwxr-xr-x[-rw-r--r--] | examples/flowbasic | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/stickycookies | 8 |
2 files changed, 8 insertions, 11 deletions
diff --git a/examples/flowbasic b/examples/flowbasic index 4a87b86a..d8d55caa 100644..100755 --- a/examples/flowbasic +++ b/examples/flowbasic @@ -8,7 +8,7 @@ Note that request and response messages are not automatically replied to, so we need to implement handlers to do this. """ -from mitmproxy import flow +from mitmproxy import flow, controller from mitmproxy.proxy import ProxyServer, ProxyConfig @@ -19,18 +19,15 @@ class MyMaster(flow.FlowMaster): except KeyboardInterrupt: self.shutdown() + @controller.handler def handle_request(self, f): f = flow.FlowMaster.handle_request(self, f) - if f: - f.reply() - return f + print(f) + @controller.handler def handle_response(self, f): f = flow.FlowMaster.handle_response(self, f) - if f: - f.reply() print(f) - return f config = ProxyConfig( diff --git a/examples/stickycookies b/examples/stickycookies index 8f11de8d..43e5371d 100644..100755 --- a/examples/stickycookies +++ b/examples/stickycookies @@ -21,19 +21,19 @@ class StickyMaster(controller.Master): except KeyboardInterrupt: self.shutdown() - def handle_request(self, flow): + @controller.handler + def request(self, flow): hid = (flow.request.host, flow.request.port) if "cookie" in flow.request.headers: self.stickyhosts[hid] = flow.request.headers.get_all("cookie") elif hid in self.stickyhosts: flow.request.headers.set_all("cookie", self.stickyhosts[hid]) - flow.reply() - def handle_response(self, flow): + @controller.handler + def response(self, flow): hid = (flow.request.host, flow.request.port) if "set-cookie" in flow.response.headers: self.stickyhosts[hid] = flow.response.headers.get_all("set-cookie") - flow.reply() config = proxy.ProxyConfig(port=8080) |