Skip to content

Commit b99c4ce

Browse files
committed
Remove request body chunking
1 parent 62a25af commit b99c4ce

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

modules/api.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def cookiedict(cookies: http.cookies.SimpleCookie):
9696

9797

9898
@contextlib.asynccontextmanager
99-
async def request(method: str, url: str, read=True, until: list[bytes] = None, **kwargs):
99+
async def request(method: str, url: str, read=True, **kwargs):
100100
timeout = kwargs.pop("timeout", None)
101101
if not timeout:
102102
timeout = globals.settings.request_timeout
@@ -178,20 +178,7 @@ async def request(method: str, url: str, read=True, until: list[bytes] = None, *
178178
ddos_guard_cookies.update(cookiedict(mark_req.cookies))
179179
continue
180180
if read:
181-
if until:
182-
offset = 0
183-
async for chunk in req.content.iter_any():
184-
if not chunk:
185-
break
186-
res += chunk
187-
while (new_offset := res.find(until[0], offset)) != -1:
188-
offset = new_offset + len(until.pop(0))
189-
if not until:
190-
break
191-
if not until:
192-
break
193-
else:
194-
res += await req.read()
181+
res += await req.read()
195182
yield res, req
196183
break
197184
except (aiohttp.ClientError, asyncio.TimeoutError) as exc:
@@ -273,7 +260,7 @@ def raise_f95zone_error(res: bytes | dict, return_login=False):
273260

274261
async def is_logged_in():
275262
global xf_token
276-
async with request("GET", check_login_page, until=[b"_xfToken", b">"]) as (res, req):
263+
async with request("GET", check_login_page) as (res, req):
277264
if not 200 <= req.status < 300:
278265
res += await req.content.read()
279266
if not raise_f95zone_error(res, return_login=True):
@@ -555,7 +542,7 @@ async def fast_check(games: list[Game], full_queue: list[tuple[Game, str]]=None,
555542
async def full_check(game: Game, version: str):
556543
async with full_checks:
557544

558-
async with request("GET", game.url, until=[b"</article>"], timeout=globals.settings.request_timeout * 2) as (res, req):
545+
async with request("GET", game.url, timeout=globals.settings.request_timeout * 2) as (res, req):
559546
raise_f95zone_error(res)
560547
if req.status in (403, 404):
561548
if not game.archived:

0 commit comments

Comments
 (0)