aboutsummaryrefslogtreecommitdiffstats
path: root/examples/complex/change_upstream_proxy.py
diff options
context:
space:
mode:
authorArushit Mudgal <rshtmudgal@gmail.com>2018-02-04 02:07:33 +0530
committerMaximilian Hils <git@maximilianhils.com>2018-02-03 21:37:33 +0100
commit91834f98ccb1e586dabb9c269c369a094a00f2f0 (patch)
tree6ccbdbdd1bf81d3ce2b3cf8c979648eaf255402c /examples/complex/change_upstream_proxy.py
parent773325262790b419e2865adcf9b151f7cbc5d17a (diff)
downloadmitmproxy-91834f98ccb1e586dabb9c269c369a094a00f2f0.tar.gz
mitmproxy-91834f98ccb1e586dabb9c269c369a094a00f2f0.tar.bz2
mitmproxy-91834f98ccb1e586dabb9c269c369a094a00f2f0.zip
Extend mypy checking, fix #2194 (#2819)
Diffstat (limited to 'examples/complex/change_upstream_proxy.py')
-rw-r--r--examples/complex/change_upstream_proxy.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/complex/change_upstream_proxy.py b/examples/complex/change_upstream_proxy.py
index 49d5379f..089a9df5 100644
--- a/examples/complex/change_upstream_proxy.py
+++ b/examples/complex/change_upstream_proxy.py
@@ -1,3 +1,6 @@
+from mitmproxy import http
+import typing
+
# This scripts demonstrates how mitmproxy can switch to a second/different upstream proxy
# in upstream proxy mode.
#
@@ -6,7 +9,7 @@
# If you want to change the target server, you should modify flow.request.host and flow.request.port
-def proxy_address(flow):
+def proxy_address(flow: http.HTTPFlow) -> typing.Tuple[str, int]:
# Poor man's loadbalancing: route every second domain through the alternative proxy.
if hash(flow.request.host) % 2 == 1:
return ("localhost", 8082)
@@ -14,7 +17,7 @@ def proxy_address(flow):
return ("localhost", 8081)
-def request(flow):
+def request(flow: http.HTTPFlow) -> None:
if flow.request.method == "CONNECT":
# If the decision is done by domain, one could also modify the server address here.
# We do it after CONNECT here to have the request data available as well.