Show an error when attempting to decode invalid data.

This commit is contained in:
Aldo Cortesi 2013-07-29 18:14:11 +12:00
parent d54398cc79
commit 5f0b5532bc
2 changed files with 10 additions and 3 deletions

View File

@ -576,7 +576,8 @@ class FlowView(common.WWrap):
self.flow.backup()
e = conn.headers.get_first("content-encoding", "identity")
if e != "identity":
conn.decode()
if not conn.decode():
self.master.statusbar.message("Could not decode - invalid data?")
else:
self.master.prompt_onekey(
"Select encoding: ",

View File

@ -221,15 +221,21 @@ class HTTPMsg(StateObject):
Decodes content based on the current Content-Encoding header, then
removes the header. If there is no Content-Encoding header, no
action is taken.
Returns True if decoding succeeded, False otherwise.
"""
ce = self.headers.get_first("content-encoding")
if not self.content or ce not in encoding.ENCODINGS:
return
self.content = encoding.decode(
return False
data = encoding.decode(
ce,
self.content
)
if data is None:
return False
self.content = data
del self.headers["content-encoding"]
return True
def encode(self, e):
"""