forked from MirrorHub/synapse
Throw sensible errors on not-json when allowing empty body
This commit is contained in:
parent
41cd778d66
commit
6b59650753
1 changed files with 4 additions and 1 deletions
|
@ -44,7 +44,10 @@ def parse_request_allow_empty(request):
|
||||||
content = request.content.read()
|
content = request.content.read()
|
||||||
if content is None or content == '':
|
if content is None or content == '':
|
||||||
return None
|
return None
|
||||||
return simplejson.loads(content)
|
try:
|
||||||
|
return simplejson.loads(content)
|
||||||
|
except simplejson.JSONDecodeError:
|
||||||
|
raise SynapseError(400, "Content not JSON.")
|
||||||
|
|
||||||
|
|
||||||
def parse_json_dict_from_request(request):
|
def parse_json_dict_from_request(request):
|
||||||
|
|
Loading…
Add table
Reference in a new issue