aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/redirect_requests.py19
-rw-r--r--libmproxy/console/contentview.py2
-rw-r--r--libmproxy/console/flowview.py6
-rw-r--r--libmproxy/console/help.py6
4 files changed, 30 insertions, 3 deletions
diff --git a/examples/redirect_requests.py b/examples/redirect_requests.py
new file mode 100644
index 00000000..3a3ad300
--- /dev/null
+++ b/examples/redirect_requests.py
@@ -0,0 +1,19 @@
+from libmproxy.flow import Response
+from netlib.odict import ODictCaseless
+
+"""
+This example shows two ways to redirect flows to other destinations.
+"""
+
+def request(context, flow):
+ if flow.request.host.endswith("example.com"):
+ resp = Response(flow.request,
+ [1,1],
+ 200, "OK",
+ ODictCaseless([["Content-Type","text/html"]]),
+ "helloworld",
+ None)
+ flow.request.reply(resp)
+ if flow.request.host.endswith("example.org"):
+ flow.request.host = "mitmproxy.org"
+ flow.request.headers["Host"] = ["mitmproxy.org"]
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py
index 61c7adb5..53841c73 100644
--- a/libmproxy/console/contentview.py
+++ b/libmproxy/console/contentview.py
@@ -137,7 +137,7 @@ class ViewXML:
class ViewJSON:
name = "JSON"
- prompt = ("json", "j")
+ prompt = ("json", "s")
content_types = ["application/json"]
def __call__(self, hdrs, content, limit):
lines = utils.pretty_json(content)
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 5f1d261f..8932b912 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -34,10 +34,14 @@ def _mkhelp():
[("text", ": automatic detection")]
),
(None,
- common.highlight_key("hex", "h") +
+ common.highlight_key("hex", "e") +
[("text", ": Hex")]
),
(None,
+ common.highlight_key("html", "h") +
+ [("text", ": HTML")]
+ ),
+ (None,
common.highlight_key("image", "i") +
[("text", ": Image")]
),
diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py
index 40f81955..de373083 100644
--- a/libmproxy/console/help.py
+++ b/libmproxy/console/help.py
@@ -57,10 +57,14 @@ class HelpView(urwid.ListBox):
[("text", ": automatic detection")]
),
(None,
- common.highlight_key("hex", "h") +
+ common.highlight_key("hex", "e") +
[("text", ": Hex")]
),
(None,
+ common.highlight_key("html", "h") +
+ [("text", ": HTML")]
+ ),
+ (None,
common.highlight_key("image", "i") +
[("text", ": Image")]
),