fix issues in garbage collected issues #136 and #166

pull/195/head
RajaSunrise 2024-08-07 11:29:48 +08:00
rodzic 63b1546bbb
commit fe34019fd2
3 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -55,7 +55,7 @@ def graphiql_from(Query, Mutation=None):
context_value = req.preserve()
# get all incoming data and parses as json
body = await res.get_json()
body = res.get_json()
query = body["query"]
variables = body.get("variables", None)

Wyświetl plik

@ -47,7 +47,7 @@ Similar to `res.get_data()`, `res.get_json()` will decode the json as dict.
async def upload_json(res, req):
print(f"Posted to {req.get_url()}")
# await all the data and parses as json, returns None if fail
info = await res.get_json()
info = res.get_json()
print(info)
@ -79,7 +79,7 @@ async def upload_multiple(res, req):
content_type = req.get_header("content-type")
# we can check the Content-Type to accept multiple formats
if content_type == "application/json":
data = await res.get_json()
data = res.get_json()
elif content_type == "application/x-www-form-urlencoded":
data = await res.get_form_urlencoded()
else:

Wyświetl plik

@ -1585,8 +1585,8 @@ class AppResponse:
except Exception:
return None # invalid encoding
async def get_json(self):
data = await self.get_data()
def get_json(self):
data = self.get_data()
try:
return self.app._json_serializer.loads(data.getvalue().decode("utf-8"))
except Exception: