aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/tools/console/consoleaddons.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index 298770c1..b10d27e4 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -5,6 +5,7 @@ from mitmproxy import ctx
from mitmproxy import command
from mitmproxy import exceptions
from mitmproxy import flow
+from mitmproxy import http
from mitmproxy import contentviews
from mitmproxy.utils import strutils
import mitmproxy.types
@@ -378,6 +379,12 @@ class ConsoleAddon:
# but for now it is.
if not flow:
raise exceptions.CommandError("No flow selected.")
+ require_dummy_response = (
+ part in ("response-headers", "response-body", "set-cookies") and
+ flow.response is None
+ )
+ if require_dummy_response:
+ flow.response = http.HTTPResponse.make()
if part == "cookies":
self.master.switch_view("edit_focus_cookies")
elif part == "form":
@@ -395,8 +402,6 @@ class ConsoleAddon:
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