Skip to content

Commit

Permalink
BGDIINF_SB-1898: Avoid crash if request is missing the content-type h…
Browse files Browse the repository at this point in the history
…eader.

On prod we had some non authorized requests without content-type header
that crashed the service.
  • Loading branch information
ltshb committed Jul 9, 2021
1 parent 94d9af3 commit 295d007
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/stac_api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def custom_exception_handler(exc, context):

if (
context['request']._request.method.upper() in ["PATCH", "POST", "PUT"] and
'application/json' in context['request']._request.headers['content-type'].lower()
'application/json' in context['request']._request.headers.get('content-type',
'').lower()
):
extra["request.payload"] = context['request'].data

Expand Down

0 comments on commit 295d007

Please sign in to comment.