jawah / niquests

“Safest, Fastest, Easiest, and Most advanced” Python HTTP Client. Production Ready! Drop-in replacement for Requests. HTTP/1.1, HTTP/2, and HTTP/3 supported. With WebSocket!
https://niquests.readthedocs.io/en/latest/
Apache License 2.0
1.06k stars 23 forks source link

Fix `AsyncResponse.iter_lines()` #182

Closed vrslev closed 3 days ago

vrslev commented 4 days ago

Doesn't work now. Causes an exception:TypeError: 'async for' requires an object with __aiter__ method, got coroutine. MRE:

import asyncio

import niquests

async def main() -> None:
    async with niquests.AsyncSession() as session:
        response: niquests.AsyncResponse = session.post(..., stream=True)
        async for line in response.iter_lines():
            print(line)

asyncio.run(main())