_stream in async client raises RuntimeError processing HTTP errors (#266)

Fixes a bug processing errors in async client. When response in _stream has an HTTP error, the process raises a RuntimeError("Attempted to call a sync iterator on an async stream.") due to use of e.response.read() instead of await e.response.aread()
This commit is contained in:
Oscar Neira 2024-08-30 01:45:57 +02:00 committed by GitHub
parent d98f646929
commit 81edab1b64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -495,7 +495,7 @@ class AsyncClient(BaseClient):
try:
r.raise_for_status()
except httpx.HTTPStatusError as e:
e.response.read()
await e.response.aread()
raise ResponseError(e.response.text, e.response.status_code) from None
async for line in r.aiter_lines():