diff --git a/src/microdot/asgi.py b/src/microdot/asgi.py index 1894904..caf5b47 100644 --- a/src/microdot/asgi.py +++ b/src/microdot/asgi.py @@ -127,19 +127,17 @@ class Microdot(BaseMicrodot): monitor_task = asyncio.ensure_future(cancel_monitor()) body_iter = res.body_iter().__aiter__() - res_body = b'' try: - res_body = await body_iter.__anext__() while not cancelled: # pragma: no branch - next_body = await body_iter.__anext__() + res_body = await body_iter.__anext__() await send({'type': 'http.response.body', 'body': res_body, 'more_body': True}) - res_body = next_body except StopAsyncIteration: - await send({'type': 'http.response.body', - 'body': res_body, - 'more_body': False}) + pass + await send({'type': 'http.response.body', + 'body': b'', + 'more_body': False}) if hasattr(body_iter, 'aclose'): # pragma: no branch await body_iter.aclose() cancelled = True