backup for flow.decode/encode

This commit is contained in:
Miroslav 2018-02-12 20:39:53 +02:00
parent 8eec21d553
commit f21979f6ad
2 changed files with 4 additions and 1 deletions

View File

@ -164,6 +164,7 @@ class Core:
for f in flows:
p = getattr(f, part, None)
if p:
f.backup()
p.decode()
updated.append(f)
ctx.master.addons.trigger("update", updated)
@ -205,6 +206,7 @@ class Core:
if p:
current_enc = p.headers.get("content-encoding", "identity")
if current_enc == "identity":
f.backup()
p.encode(enc)
updated.append(f)
ctx.master.addons.trigger("update", updated)

View File

@ -379,11 +379,12 @@ class ConsoleAddon:
# but for now it is.
if not flow:
raise exceptions.CommandError("No flow selected.")
flow.backup()
require_dummy_response = (
part in ("response-headers", "response-body", "set-cookies") and
flow.response is None
)
flow.backup()
if require_dummy_response:
flow.response = http.HTTPResponse.make()
if part == "cookies":