mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Add U shortcut to add user-agent strings to global Headers editor.
This commit is contained in:
parent
3fc9af63c1
commit
9c009a872e
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user