This commit is contained in:
yumoqing 2025-09-02 17:02:26 +08:00
parent 27a3d91578
commit 109699c287

View File

@ -122,7 +122,7 @@ class UAPI:
self.auth_ret = None
self.sor = sor
async def rendertmpl(self, tmplstr, params={}):
def rendertmpl(self, tmplstr, params={}):
if tmplstr is None:
return None
ns = self.env.copy()
@ -170,6 +170,7 @@ class UAPI:
async def stream_linify(self, upappid, apiname, callerid, params={}):
gen = liner(self.__call__(upappid, apiname, callerid, params=params))
async for line in gen:
debug(f'{line=},{type(line)=}')
filter = self.uapi.chunk_match
if filter:
filter = filter.encode('utf-8')
@ -208,13 +209,13 @@ class UAPI:
async def stream_resp(self, api):
url = self.env.get('baseurl') + api.path
method = api.httpmethod
headers = await self.rendertmpl(api.headers)
headers = self.rendertmpl(api.headers)
try:
headers = json.loads(headers)
except Exception as e:
exception(f'{e}, {headers=},{api.headers=}')
raise e
body = await self.rendertmpl(api.data)
body = self.rendertmpl(api.data)
if body:
try:
bdy = json.loads(body)
@ -222,7 +223,7 @@ class UAPI:
except Exception as e:
exception(f'{e}, {body=},{api.data=}')
body = None
_params = await self.rendertmpl(api.params)
_params = self.rendertmpl(api.params)
if _params:
_params = json.loads(_params)
debug(f'{headers=}, {body=}. {method=}, {url=}')