From 5c5f3d6d22d85e679446c9e3f21b9eeb17a5a75b Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Fri, 7 Jul 2023 07:56:46 -0700 Subject: [PATCH] Account for content type being included twice Chrome appears to be providing content type twice sometimes, this results in load_json_body not being called. Content-Type: application/json, application/json; charset=utf-8 --- graphql_server/flask/graphqlview.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graphql_server/flask/graphqlview.py b/graphql_server/flask/graphqlview.py index 7440f82..7770d1f 100644 --- a/graphql_server/flask/graphqlview.py +++ b/graphql_server/flask/graphqlview.py @@ -164,15 +164,15 @@ def parse_body(): # We use mimetype here since we don't need the other # information provided by content_type content_type = request.mimetype - if content_type == "application/graphql": + if "application/graphql" in content_type: return {"query": request.data.decode("utf8")} - elif content_type == "application/json": + elif "application/json" in content_type: return load_json_body(request.data.decode("utf8")) - elif content_type in ( - "application/x-www-form-urlencoded", - "multipart/form-data", + elif ( + "application/x-www-form-urlencoded" in content_type + or "multipart/form-data" in content_type ): return request.form