Fix for werkzeug > 0.15

Werkzeug is pickier about how Content-Type is handled in general.
In this case we are now explicitly checking for either Content-Type
being '' or being non-existant in addition to Content-Type being set
to json for decoding the body.

Change-Id: Ia5a7750cff833aa90f7fc446f396c270343fc590
(cherry picked from commit 3d31723b3b)
This commit is contained in:
morgan fainberg 2019-05-01 09:21:07 -07:00 committed by Sam Morrison
parent 2de401b79b
commit 9b73d7dfe0
1 changed files with 1 additions and 1 deletions

View File

@ -38,7 +38,7 @@ def json_body_before_request():
# Explicitly check if the content is supposed to be json.
if (flask.request.is_json
or flask.request.headers['Content-Type'] == ''):
or flask.request.headers.get('Content-Type', '') == ''):
json_decoded = flask.request.get_json(force=True)
if not isinstance(json_decoded, dict):
# In the case that the returned value was not a dict, force