This commit is contained in:
yumoqing 2023-08-10 17:46:09 +08:00
parent cfa5e822d5
commit 1feb656eb1

View File

@ -107,29 +107,30 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
return fname return fname
async def getPostData(self,request: Request) -> dict: async def getPostData(self,request: Request) -> dict:
qd = {}
if request.query:
qd = multiDict2Dict(request.query)
reader = None reader = None
try: try:
reader = await request.multipart() reader = await request.multipart()
except: except:
print('reader is None') # print('reader is None')
pass pass
if reader is None: if reader is None:
md = await request.post() pd = await request.post()
if md == {}: pd = multiDict2Dict(pd)
if request.query: if pd == {}:
return multiDict2Dict(request.query) if request.can_read_body:
else: x = await request.read()
if request.can_read_body: try:
x = await request.read() pd = json.loads(x)
try: except:
md = json.loads(x) # print('body is not a json')
except: pass
print('body is not a json') qd.update(pd)
print('request.query is None, md=', md) # print(f'{qd=} reader is None, {pd=}')
ns = multiDict2Dict(md) return qd
print(f'{ns=} reader is None, {request.query=}') ns = qd
return ns
ns = {}
while 1: while 1:
try: try:
field = await reader.next() field = await reader.next()