diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-08 16:02:31 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-08 17:03:34 +0200 |
commit | ebd539b49f0706918e979dc921cf454ae448eaf9 (patch) | |
tree | 1c541027c735e18c7486d5d9ebda7367278ac244 /examples/stickycookies | |
parent | d06b4bfa4e4cc51e903b49e246d7771726a3e3a4 (diff) | |
download | mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.gz mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.bz2 mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.zip |
update examples, fix #353
Diffstat (limited to 'examples/stickycookies')
-rwxr-xr-x | examples/stickycookies | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/stickycookies b/examples/stickycookies index 2aab31d6..d2368e22 100755 --- a/examples/stickycookies +++ b/examples/stickycookies @@ -1,9 +1,9 @@ #!/usr/bin/env python """ This example builds on mitmproxy's base proxying infrastructure to -implement functionality similar to the "sticky cookies" option. This is at -a lower level than the Flow mechanism, so we're dealing directly with -request and response objects. +implement functionality similar to the "sticky cookies" option. + +Heads Up: In the majority of cases, you want to use inline scripts. """ import os from libmproxy import controller, proxy @@ -21,19 +21,19 @@ class StickyMaster(controller.Master): except KeyboardInterrupt: self.shutdown() - def handle_request(self, msg): - hid = (msg.host, msg.port) - if msg.headers["cookie"]: - self.stickyhosts[hid] = msg.headers["cookie"] + def handle_request(self, flow): + hid = (flow.request.host, flow.request.port) + if flow.request.headers["cookie"]: + self.stickyhosts[hid] = flow.request.headers["cookie"] elif hid in self.stickyhosts: - msg.headers["cookie"] = self.stickyhosts[hid] - msg.reply() - - def handle_response(self, msg): - hid = (msg.request.host, msg.request.port) - if msg.headers["set-cookie"]: - self.stickyhosts[hid] = msg.headers["set-cookie"] - msg.reply() + flow.request.headers["cookie"] = self.stickyhosts[hid] + flow.reply() + + def handle_response(self, flow): + hid = (flow.request.host, flow.request.port) + if flow.response.headers["set-cookie"]: + self.stickyhosts[hid] = flow.response.headers["set-cookie"] + flow.reply() config = proxy.ProxyConfig( |