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)
else:
if request.can_read_body: if request.can_read_body:
x = await request.read() x = await request.read()
try: try:
md = json.loads(x) pd = json.loads(x)
except: except:
print('body is not a json') # print('body is not a json')
print('request.query is None, md=', md) pass
ns = multiDict2Dict(md) qd.update(pd)
print(f'{ns=} reader is None, {request.query=}') # print(f'{qd=} reader is None, {pd=}')
return ns return qd
ns = {} ns = qd
while 1: while 1:
try: try:
field = await reader.next() field = await reader.next()