From 1feb656eb127973807b3fb8a5c3513fd58dc153a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 10 Aug 2023 17:46:09 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 54e7a27..eb5e864 100755 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -107,29 +107,30 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): return fname async def getPostData(self,request: Request) -> dict: + qd = {} + if request.query: + qd = multiDict2Dict(request.query) reader = None try: reader = await request.multipart() except: - print('reader is None') + # print('reader is None') pass if reader is None: - md = await request.post() - if md == {}: - if request.query: - return multiDict2Dict(request.query) - else: - if request.can_read_body: - x = await request.read() - try: - md = json.loads(x) - except: - print('body is not a json') - print('request.query is None, md=', md) - ns = multiDict2Dict(md) - print(f'{ns=} reader is None, {request.query=}') - return ns - ns = {} + pd = await request.post() + pd = multiDict2Dict(pd) + if pd == {}: + if request.can_read_body: + x = await request.read() + try: + pd = json.loads(x) + except: + # print('body is not a json') + pass + qd.update(pd) + # print(f'{qd=} reader is None, {pd=}') + return qd + ns = qd while 1: try: field = await reader.next()