Browse Source

Send no ID for batch request errors

Fixes #54
master
Neil Booth 8 years ago
parent
commit
625508f5c6
  1. 7
      lib/jsonrpc.py

7
lib/jsonrpc.py

@ -211,16 +211,17 @@ class JSONRPC(asyncio.Protocol, LoggedClass):
if self.transport.is_closing():
return
id_ = payload.get('id') if isinstance(payload, dict) else None
try:
data = (json.dumps(payload) + '\n').encode()
except TypeError:
msg = 'JSON encoding failure: {}'.format(payload)
self.logger.error(msg)
self.send_json_error(msg, self.INTERNAL_ERROR, payload.get('id'))
self.send_json_error(msg, self.INTERNAL_ERROR, id_)
else:
if len(data) > max(1000, self.max_send):
self.send_json_error('request too large', self.INVALID_REQUEST,
payload.get('id'))
self.send_json_error('request too large',
self.INVALID_REQUEST, id_)
raise self.LargeRequestError
else:
self.send_count += 1

Loading…
Cancel
Save