bugfix
This commit is contained in:
parent
003ff36471
commit
9758b24915
@ -268,8 +268,10 @@ class JsonHttpAPI:
|
|||||||
jd = json.loads(a)
|
jd = json.loads(a)
|
||||||
await self.user_stream_func(jd)
|
await self.user_stream_func(jd)
|
||||||
|
|
||||||
|
async def chunk_handle(self, chunk, chunk_lead, chunk_end):
|
||||||
|
return chunk
|
||||||
|
|
||||||
async def __call__(self, url, method='GET', ns={},
|
async def __call__(self, url, method='GET', ns={},
|
||||||
stream=False,
|
|
||||||
headerstmpl=None,
|
headerstmpl=None,
|
||||||
paramstmpl=None,
|
paramstmpl=None,
|
||||||
datatmpl=None,
|
datatmpl=None,
|
||||||
@ -277,6 +279,7 @@ class JsonHttpAPI:
|
|||||||
chunk_end="[done]",
|
chunk_end="[done]",
|
||||||
resptmpl=None):
|
resptmpl=None):
|
||||||
headers = None
|
headers = None
|
||||||
|
self.chunk_buffer = ''
|
||||||
ns1 = self.env.copy()
|
ns1 = self.env.copy()
|
||||||
ns1.update(ns)
|
ns1.update(ns)
|
||||||
if headerstmpl:
|
if headerstmpl:
|
||||||
@ -286,16 +289,11 @@ class JsonHttpAPI:
|
|||||||
if paramstmpl:
|
if paramstmpl:
|
||||||
params = json.loads(self.te.renders(paramstmpl, ns1))
|
params = json.loads(self.te.renders(paramstmpl, ns1))
|
||||||
data = None
|
data = None
|
||||||
|
stream = False
|
||||||
if datatmpl:
|
if datatmpl:
|
||||||
datadic = json.loads(self.te.renders(datatmpl, ns1))
|
datadic = json.loads(self.te.renders(datatmpl, ns1))
|
||||||
|
stream = atadic.get('stream', False)
|
||||||
data = json.dumps(datadic, ensure_ascii=False)
|
data = json.dumps(datadic, ensure_ascii=False)
|
||||||
"""
|
|
||||||
data = FormData()
|
|
||||||
for k,v in datadic.items():
|
|
||||||
data.add_field(k, v)
|
|
||||||
headers['Content-Type'] = 'multipart/form-data'
|
|
||||||
"""
|
|
||||||
info(f'{data=},{ns=}, {headers=}')
|
|
||||||
hc = HttpClient()
|
hc = HttpClient()
|
||||||
async for d in self.hc(url, method=method,
|
async for d in self.hc(url, method=method,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
@ -304,10 +302,10 @@ class JsonHttpAPI:
|
|||||||
data=data):
|
data=data):
|
||||||
if stream:
|
if stream:
|
||||||
d = self.chunk_handle(d, chunk_leading, chunk_end)
|
d = self.chunk_handle(d, chunk_leading, chunk_end)
|
||||||
if isinstance(d, dict) and resptmpl:
|
if resptmpl:
|
||||||
ds = self.te.renders(resptmpl, d)
|
dic = json.loads(d)
|
||||||
yield json.loads(ds)
|
ns1.update(dic)
|
||||||
else:
|
d = self.te.renders(resptmpl, ns1)
|
||||||
yield d
|
yield d
|
||||||
|
|
||||||
async def call(self, url, method='GET', ns={},
|
async def call(self, url, method='GET', ns={},
|
||||||
|
Loading…
Reference in New Issue
Block a user