Permalink
Browse files

Merge pull request #21 from tasleson/fix_json_rpc

main.py: Return 'jsonrpc="2.0"' in response
  • Loading branch information...
2 parents 14616e6 + cdbf354 commit 7c0adc4a234dc21c69c20210329e207d4f80fe43 @tasleson tasleson committed Apr 26, 2017
Showing with 6 additions and 3 deletions.
  1. +3 −1 client
  2. +3 −2 targetd/main.py
View
4 client
@@ -30,7 +30,7 @@
# Test client to exercise targetd.
#
-
+import sys
import json
import time
import socket
@@ -80,6 +80,8 @@ def jsonrequest(method, params=None):
response_data = response_obj.read().decode('utf-8')
#print('Got response: %s' % response_data)
response = json.loads(response_data)
+ #Ensure we have version string
+ assert response.get('jsonrpc') == "2.0"
if response.get('error') is not None:
if response['error']['code'] <= 0:
raise Exception(response['error'].get('message', ''))
View
@@ -133,12 +133,13 @@ def do_POST(self):
log.debug(traceback.format_exc())
raise
- rpcdata = json.dumps(dict(result=result, id=id_num))
+ rpcdata = json.dumps(dict(result=result, id=id_num, jsonrpc="2.0"))
except:
log.debug(traceback.format_exc())
log.debug('Error=%s, msg=%s' % (error[0], error[1]))
rpcdata = json.dumps(
- dict(error=dict(code=error[0], message=error[1]), id=id_num))
+ dict(error=dict(code=error[0], message=error[1]),
+ id=id_num, jsonrpc="2.0"))
finally:
self.wfile.write(rpcdata.encode('utf-8'))

0 comments on commit 7c0adc4

Please sign in to comment.