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/change_upstream_proxy.py | |
parent | d06b4bfa4e4cc51e903b49e246d7771726a3e3a4 (diff) | |
download | mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.gz mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.bz2 mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.zip |
update examples, fix #353
Diffstat (limited to 'examples/change_upstream_proxy.py')
-rw-r--r-- | examples/change_upstream_proxy.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/change_upstream_proxy.py b/examples/change_upstream_proxy.py index 86031d29..e063ca4f 100644 --- a/examples/change_upstream_proxy.py +++ b/examples/change_upstream_proxy.py @@ -4,17 +4,18 @@ # Usage: mitmdump -s "change_upstream_proxy.py host" from libmproxy.protocol.http import send_connect_request +alternative_upstream_proxy = ("localhost", 8082) def should_redirect(flow): - return (flow.request.host == "example.com") -alternative_upstream_proxy = ("localhost",8082) + return flow.request.host == "example.com" -def request(ctx, flow): - if flow.live and should_redirect(flow): - # If you want to change the target server, you should modify flow.request.host and flow.request.port - # flow.live.change_server should only be used by inline scripts to change the upstream proxy, - # unless you are sure that you know what you are doing. - server_changed = flow.live.change_server(alternative_upstream_proxy, persistent_change=True) - if flow.request.scheme == "https" and server_changed: - send_connect_request(flow.live.c.server_conn, flow.request.host, flow.request.port) - flow.live.c.establish_ssl(server=True) +def request(context, flow): + if flow.live and should_redirect(flow): + + # If you want to change the target server, you should modify flow.request.host and flow.request.port + # flow.live.change_server should only be used by inline scripts to change the upstream proxy, + # unless you are sure that you know what you are doing. + server_changed = flow.live.change_server(alternative_upstream_proxy, persistent_change=True) + if flow.request.scheme == "https" and server_changed: + send_connect_request(flow.live.c.server_conn, flow.request.host, flow.request.port) + flow.live.c.establish_ssl(server=True) |