Skip to content

Commit

Permalink
models: fix for cached JSON
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
  • Loading branch information
jirikuncar committed Nov 17, 2016
1 parent 6d2e622 commit 3c7e987
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions invenio_webhooks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ def extract_payload(self):
"""Extract payload from request."""
if not self.check_signature():
raise InvalidSignature('Invalid Signature')
if request.content_type == 'application/json':
return request.get_json()
if request.is_json:
# Request.get_json() could be first called with silent=True.
if hasattr(request, '_cached_json'):
delattr(request, '_cached_json')
return request.get_json(silent=False, cache=False)
elif request.content_type == 'application/x-www-form-urlencoded':
return dict(request.form)
raise InvalidPayload(request.content_type)
Expand Down

0 comments on commit 3c7e987

Please sign in to comment.