aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-09-02 11:50:17 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-09-02 11:50:17 +1200
commit9c009a872ef02f3692c1b6eb1d729a1e79eed086 (patch)
tree6e53f9b2ae3941101db16efedcd52535125ca645
parent3fc9af63c1574502c89f3ac9cd4c8ed9a078a800 (diff)
downloadmitmproxy-9c009a872ef02f3692c1b6eb1d729a1e79eed086.tar.gz
mitmproxy-9c009a872ef02f3692c1b6eb1d729a1e79eed086.tar.bz2
mitmproxy-9c009a872ef02f3692c1b6eb1d729a1e79eed086.zip
Add U shortcut to add user-agent strings to global Headers editor.
-rw-r--r--libmproxy/console/grideditor.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/libmproxy/console/grideditor.py b/libmproxy/console/grideditor.py
index 0c07b60d..314d6e88 100644
--- a/libmproxy/console/grideditor.py
+++ b/libmproxy/console/grideditor.py
@@ -397,7 +397,6 @@ class HeaderEditor(GridEditor):
headings = ("Key", "Value")
def make_help(self):
h = GridEditor.make_help(self)
-
text = []
text.append(urwid.Text([("text", "Special keys:\n")]))
keys = [
@@ -460,6 +459,38 @@ class SetHeadersEditor(GridEditor):
return "Invalid filter specification"
return False
+ def make_help(self):
+ h = GridEditor.make_help(self)
+ text = []
+ text.append(urwid.Text([("text", "Special keys:\n")]))
+ keys = [
+ ("U", "add User-Agent header"),
+ ]
+ text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
+ text.append(urwid.Text([("text", "\n")]))
+ text.extend(h)
+ return text
+
+ def set_user_agent(self, k):
+ ua = http_uastrings.get_by_shortcut(k)
+ if ua:
+ self.walker.add_value(
+ [
+ ".*",
+ "User-Agent",
+ ua[2]
+ ]
+ )
+
+ def handle_key(self, key):
+ if key == "U":
+ self.master.prompt_onekey(
+ "Add User-Agent header:",
+ [(i[0], i[1]) for i in http_uastrings.UASTRINGS],
+ self.set_user_agent,
+ )
+ return True
+
class PathEditor(GridEditor):
title = "Editing URL path components"