From 4cb71227a1bf73f4b452e42ca08456e7d50ce6b0 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 10 Jul 2025 11:27:25 +0800 Subject: [PATCH] bugfix --- appPublic/streamhttpclient.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/appPublic/streamhttpclient.py b/appPublic/streamhttpclient.py index 8d31220..35851ff 100755 --- a/appPublic/streamhttpclient.py +++ b/appPublic/streamhttpclient.py @@ -11,21 +11,17 @@ import os from appPublic.log import exception, debug async def liner(async_gen): - remainer = '' + remainer = b'' async for chunk in async_gen: - chunk = chunk.decode('utf-8') + # chunk = chunk.decode('utf-8') d = remainer + chunk - lst = d.split('\n', 1) - if len(lst) == 2: - if lst[0]: - yield lst[0] - remainer = lst[1] - else: - remainer = lst[0] - for l in remainer.split('\n'): - if l: - await asyncio.sleep(0) - yield l + lst = d.split(b'\n') + cnt = len(lst) + for c in range(cnt-1): + yield lst[c] + remainer = lst[-1] + if remainer != b'': + yield remainer def get_non_verify_ssl(): ssl_context = ssl.create_default_context(cafile=certifi.where())