Skip to content

Commit 1c0fbcf

Browse files
committed
OS-90: ensure all gql calls have check of conten-type, if no - raise 415
1 parent a625b4f commit 1c0fbcf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

openIMIS/openIMIS/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.db import connection, transaction
2-
from django.http import HttpResponseNotAllowed
2+
from django.http import HttpResponseNotAllowed, HttpResponse
33
from django.http.response import HttpResponseBadRequest
44
from .dataloaders import get_dataloaders
55
from . import tracer
@@ -86,6 +86,11 @@ def parse_body(self, request):
8686
def execute_graphql_request(
8787
self, request, data, query, variables, operation_name, show_graphiql=False
8888
):
89+
if not request or getattr(request, "content_type", "") != "application/json":
90+
raise HttpError(HttpResponse(
91+
"Unsupported Media Type: The server only accepts application/json requests.",
92+
status=415,
93+
))
8994
if not query:
9095
if show_graphiql:
9196
return None

0 commit comments

Comments
 (0)