1
- import json
2
- import six
3
1
from functools import partial
4
2
from cgi import parse_header
5
3
6
4
7
5
from promise import Promise
8
6
from sanic .response import HTTPResponse
9
7
from sanic .views import HTTPMethodView
10
- from sanic .exceptions import SanicException
11
8
12
9
from graphql .type .schema import GraphQLSchema
13
10
from graphql .execution .executors .asyncio import AsyncioExecutor
@@ -39,7 +36,6 @@ def __init__(self, **kwargs):
39
36
if hasattr (self , key ):
40
37
setattr (self , key , value )
41
38
42
-
43
39
self ._enable_async = self ._enable_async and isinstance (kwargs .get ('executor' ), AsyncioExecutor )
44
40
assert isinstance (self .schema , GraphQLSchema ), 'A Schema is required to be provided to GraphQLView.'
45
41
@@ -135,8 +131,7 @@ def parse_body(self, request):
135
131
elif content_type == 'application/json' :
136
132
return load_json_body (request .body .decode ('utf8' ))
137
133
138
- elif content_type == 'application/x-www-form-urlencoded' \
139
- or content_type == 'multipart/form-data' :
134
+ elif content_type in ('application/x-www-form-urlencoded' , 'multipart/form-data' ):
140
135
return request .form
141
136
142
137
return {}
@@ -147,7 +142,7 @@ def get_mime_type(request):
147
142
# information provided by content_type
148
143
if 'content-type' not in request .headers :
149
144
return None
150
-
145
+
151
146
mimetype , _ = parse_header (request .headers ['content-type' ])
152
147
return mimetype
153
148
0 commit comments