Skip to content

Commit

Permalink
json_body: read bodyfile ourselves, to check if it is empty.
Browse files Browse the repository at this point in the history
Passing an empty bodyfile to json.load gives a ValueError.
  • Loading branch information
mauritsvanrees committed Nov 2, 2023
1 parent a1d75b4 commit 07821b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plone/restapi/deserializer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def json_body(request):
# Go back to the beginning.
bodyfile.seek(0)
try:
data = json.load(bodyfile)
body = bodyfile.read()
data = {} if not body else json.loads(body)
except ValueError:
raise DeserializationError("No JSON object could be decoded")
finally:
Expand Down

0 comments on commit 07821b8

Please sign in to comment.