diff --git a/HISTORY.md b/HISTORY.md index 013fb033fa..a096d0cd98 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,15 @@ Release History =============== +3.11.0 (2024-11-20) +------------------- + +**Added** +- base_url parameter to `niquests.Session` or `niquests.AsyncSession`. automatically prefix every request emitted with it. (#179) + +**Fixed** +- warning about coroutine method 'aclose' of 'AsyncSession.resolve_redirects' was never awaited. + 3.10.3 (2024-11-13) ------------------ diff --git a/src/niquests/_async.py b/src/niquests/_async.py index 30a1d2e427..9fb1ca4728 100644 --- a/src/niquests/_async.py +++ b/src/niquests/_async.py @@ -489,12 +489,13 @@ async def on_early_response(early_response: Response) -> None: if r.lazy is True: async def _redirect_method_ref(x, y): + aiter_gen = self.resolve_redirects(x, y, yield_requests=True, **kwargs) try: - return await self.resolve_redirects( - x, y, yield_requests=True, **kwargs - ).__anext__() + return await aiter_gen.__anext__() except StopAsyncIteration: return None + finally: + await aiter_gen.aclose() r._resolve_redirect = _redirect_method_ref @@ -567,13 +568,14 @@ async def _redirect_method_ref(x, y): # If redirects aren't being followed, store the response on the Request for Response.next(). if not allow_redirects: if r.is_redirect: + gen = self.resolve_redirects(r, request, yield_requests=True, **kwargs) + try: - gen = self.resolve_redirects( - r, request, yield_requests=True, **kwargs - ) r._next = await gen.__anext__() # type: ignore[assignment] except StopAsyncIteration: pass + finally: + await gen.aclose() if not stream: if isinstance(r, AsyncResponse):