mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Fixes json parsing of None when no json was postesd to the API
h/t @yahgwai for finding this.
This commit is contained in:
@@ -36,7 +36,7 @@ This command is used to register appointments to the PISA server. Appointments *
|
||||
"tx_id": tx_id,
|
||||
"start_time": s,
|
||||
"end_time": e,
|
||||
"dispute_delta": d }
|
||||
"to_self_delay": d }
|
||||
|
||||
`tx` **must** be the raw penalty transaction that will be encrypted before sent to the PISA server. `type(tx) = hex encoded str`
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class API:
|
||||
|
||||
logger.info("Received add_appointment request", from_addr_port="{}:{}".format(remote_addr, remote_port))
|
||||
|
||||
if request.is_json:
|
||||
# Check content type once if properly defined
|
||||
request_data = json.loads(request.get_json())
|
||||
inspector = Inspector(self.config)
|
||||
@@ -70,6 +71,11 @@ class API:
|
||||
rcode = HTTP_BAD_REQUEST
|
||||
error = "appointment rejected. Request does not match the standard"
|
||||
|
||||
else:
|
||||
rcode = HTTP_BAD_REQUEST
|
||||
error = "appointment rejected. Request is not json encoded"
|
||||
response = None
|
||||
|
||||
logger.info(
|
||||
"Sending response and disconnecting",
|
||||
from_addr_port="{}:{}".format(remote_addr, remote_port),
|
||||
|
||||
Reference in New Issue
Block a user