diff options
author | Alvaro Neira Ayuso <aneira@soleta.eu> | 2019-12-27 14:49:14 +0100 |
---|---|---|
committer | Alvaro Neira Ayuso <alvaroneay@gmail.com> | 2020-01-19 19:50:44 +0100 |
commit | db7cc0d99ef9f582a79d0ce28c0438085ee98839 (patch) | |
tree | c7bc24c813d91119f21b70948a243392dcaa136f /src/HTTPParser.py | |
parent | 445497fe01f122f9ae164d686b23e8ef9c481e33 (diff) |
(BUG) Fix crash when json message received is incomplete
Diffstat (limited to 'src/HTTPParser.py')
-rw-r--r-- | src/HTTPParser.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/HTTPParser.py b/src/HTTPParser.py index 47c2204..912a7cf 100644 --- a/src/HTTPParser.py +++ b/src/HTTPParser.py @@ -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"] |