except StopAsyncIteration as exc:
break
+ def raw(self) -> typing.Iterator[bytes]:
+ inner = self._response.raw()
+ while True:
+ try:
+ yield self._loop.run_until_complete(inner.__anext__())
+ except StopAsyncIteration as exc:
+ break
+
def close(self) -> None:
return self._loop.run_until_complete(self._response.close())
for chunk in response.stream():
body += chunk
assert body == b"Hello, world!"
+
+
+@threadpool
+def test_raw_iterator(server):
+ with httpcore.SyncConnectionPool() as http:
+ response = http.request("GET", "http://127.0.0.1:8000/", stream=True)
+ assert response.status_code == 200
+ body = b""
+ for chunk in response.raw():
+ body += chunk
+ assert body == b"Hello, world!"