aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/redirect_requests.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simple/redirect_requests.py')
-rw-r--r--examples/simple/redirect_requests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/simple/redirect_requests.py b/examples/simple/redirect_requests.py
new file mode 100644
index 00000000..51876df7
--- /dev/null
+++ b/examples/simple/redirect_requests.py
@@ -0,0 +1,11 @@
+"""
+This example shows two ways to redirect flows to another server.
+"""
+
+
+def request(flow):
+ # pretty_host takes the "Host" header of the request into account,
+ # which is useful in transparent mode where we usually only have the IP
+ # otherwise.
+ if flow.request.pretty_host == "example.org":
+ flow.request.host = "mitmproxy.org"