(BUG) Fix crash when json message received is incomplete

more_events
Alvaro Neira Ayuso 2019-12-27 14:49:14 +01:00 committed by Alvaro Neira Ayuso
parent 445497fe01
commit db7cc0d99e
1 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,12 @@ class HTTPParser:
if not self.contentLen == 0:
msgs = self.headersAlone.rstrip().split('\n')
cmd = msgs[len(msgs) - 1]
jsoncmd = json.loads(cmd)
try:
jsoncmd = json.loads(cmd)
except ValueError as e:
print ("Error: Json message incomplete")
return
if "run" in cmd:
self.cmd = jsoncmd["run"]