From fe34019fd20382060c1bed6edca99bc368abf60d Mon Sep 17 00:00:00 2001 From: RajaSunrise Date: Wed, 7 Aug 2024 11:29:48 +0800 Subject: [PATCH] fix issues in garbage collected issues #136 and #166 --- docs/graphiql.md | 2 +- docs/upload-post.md | 4 ++-- src/socketify/socketify.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/graphiql.md b/docs/graphiql.md index f41803c..b4ae13a 100644 --- a/docs/graphiql.md +++ b/docs/graphiql.md @@ -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) diff --git a/docs/upload-post.md b/docs/upload-post.md index 80db164..a4b80bb 100644 --- a/docs/upload-post.md +++ b/docs/upload-post.md @@ -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: diff --git a/src/socketify/socketify.py b/src/socketify/socketify.py index cce4fe3..d75df48 100644 --- a/src/socketify/socketify.py +++ b/src/socketify/socketify.py @@ -1585,8 +1585,8 @@ async def get_text(self, encoding="utf-8"): 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: