Merge pull request #35 from c3nav/fix/content-type

Don’t crash on empty content type
This commit is contained in:
Maurice Meyer 2019-07-18 16:30:21 +02:00 committed by GitHub
commit 44102fbd97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@ class JsonRequestBodyMiddleware:
self.get_response = get_response self.get_response = get_response
def __call__(self, request): def __call__(self, request):
is_json = request.META.get('CONTENT_TYPE').lower() == 'application/json' is_json = request.META.get('CONTENT_TYPE', '').lower() == 'application/json'
if is_json: if is_json:
try: try:
request.json_body = json.loads(request.body) request.json_body = json.loads(request.body)