From 295d00757689e407ec31b9dc0c0572422d85ba2b Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Fri, 9 Jul 2021 10:56:01 +0200 Subject: [PATCH] BGDIINF_SB-1898: Avoid crash if request is missing the content-type header. On prod we had some non authorized requests without content-type header that crashed the service. --- app/stac_api/apps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/stac_api/apps.py b/app/stac_api/apps.py index 38b9f24c..8feddc63 100644 --- a/app/stac_api/apps.py +++ b/app/stac_api/apps.py @@ -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