diff --git a/appPublic/httpclient.py b/appPublic/httpclient.py index 1d890f9..60becce 100755 --- a/appPublic/httpclient.py +++ b/appPublic/httpclient.py @@ -119,7 +119,10 @@ class HttpClient: connector = None if use_proxy: connector = ProxyConnector.from_url(self.socks5_proxy_url) - async with aiohttp.ClientSession(connector=connector) as session: + reco = aiohttp.ClientSession(connector=connector) + else: + reco = aiohttp.ClientSession() + async with reco as session: if params == {}: params = None if data == {}: @@ -130,6 +133,7 @@ class HttpClient: if headers == {}: headers = None + print(f'{method=},{ url=}, {headers=}, {data=}') resp = await session.request(method, url, params=params, data=data, @@ -220,16 +224,24 @@ class JsonHttpAPI: data = None if datatmpl: datadic = json.loads(self.te.renders(datatmpl, ns1)) + data = json.dumps(datadic, ensure_ascii=False) + """ data = FormData() for k,v in datadic.items(): data.add_field(k, v) - - info(f'{data=},{ns=}, {datatmpl=}') - resp = await self.hc.request(url, method=method, headers=headers, - response_type=None, + headers['Content-Type'] = 'multipart/form-data' + """ + info(f'{data=},{ns=}, {headers=}') + if stream_func: + resp = await self.hc.request(url, method=method, headers=headers, stream_func=stream_func, params=params, data=data) + else: + resp = await self.hc.request(url, method=method, headers=headers, + response_type=RESPONSE_JSON, + params=params, + data=data) ret = resp if resptmpl: ns1 = self.env.copy()