mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
commit
72bbb02654
@ -348,6 +348,8 @@ class ConsoleAddon:
|
||||
"reason",
|
||||
"request-headers",
|
||||
"response-headers",
|
||||
"request-body",
|
||||
"response-body",
|
||||
"status_code",
|
||||
"set-cookies",
|
||||
"url",
|
||||
@ -359,6 +361,11 @@ class ConsoleAddon:
|
||||
"""
|
||||
Edit a component of the currently focused flow.
|
||||
"""
|
||||
flow = self.master.view.focus.flow
|
||||
# This shouldn't be necessary once this command is "console.edit @focus",
|
||||
# but for now it is.
|
||||
if not flow:
|
||||
raise exceptions.CommandError("No flow selected.")
|
||||
if part == "cookies":
|
||||
self.master.switch_view("edit_focus_cookies")
|
||||
elif part == "form":
|
||||
@ -371,6 +378,21 @@ class ConsoleAddon:
|
||||
self.master.switch_view("edit_focus_request_headers")
|
||||
elif part == "response-headers":
|
||||
self.master.switch_view("edit_focus_response_headers")
|
||||
elif part in ("request-body", "response-body"):
|
||||
if part == "request-body":
|
||||
message = flow.request
|
||||
else:
|
||||
message = flow.response
|
||||
if not message:
|
||||
raise exceptions.CommandError("Flow has no {}.".format(part.split("-")[0]))
|
||||
c = self.master.spawn_editor(message.get_content(strict=False) or b"")
|
||||
# Fix an issue caused by some editors when editing a
|
||||
# request/response body. Many editors make it hard to save a
|
||||
# file without a terminating newline on the last line. When
|
||||
# editing message bodies, this can cause problems. For now, I
|
||||
# just strip the newlines off the end of the body when we return
|
||||
# from an editor.
|
||||
message.content = c.rstrip(b"\n")
|
||||
elif part == "set-cookies":
|
||||
self.master.switch_view("edit_focus_setcookies")
|
||||
elif part in ["url", "method", "status_code", "reason"]:
|
||||
|
Loading…
Reference in New Issue
Block a user