1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 14:25:01 +01:00

dspace_statistics_api/app.py: Use bounded_stream in on_post

For reasons I don't quite understand, we need to use bounded_stream
in the on_post request handler in order to use simulate_post() with
the testing client in Falcon 2.0.0. Normal runtime operation via
gunicorn does not have any issues with stream.

See: https://github.com/falconry/falcon/issues/1720
See: https://github.com/falconry/falcon/issues/1554
This commit is contained in:
Alan Orth 2020-09-26 11:50:12 +03:00
parent b06651d1ec
commit 946f0749e2
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -66,7 +66,7 @@ class AllItemsResource:
# Only attempt to read the POSTed request if its length is not 0 (or # Only attempt to read the POSTed request if its length is not 0 (or
# rather, in the Python sense, if length is not a False-y value). # rather, in the Python sense, if length is not a False-y value).
if req.content_length: if req.content_length:
doc = json.load(req.stream) doc = json.load(req.bounded_stream)
else: else:
raise falcon.HTTPBadRequest( raise falcon.HTTPBadRequest(
title="Invalid request", description=f"Request body is empty." title="Invalid request", description=f"Request body is empty."