diff --git a/gunicorn/asgi/message.py b/gunicorn/asgi/message.py index 86d97c77..73a6e7da 100644 --- a/gunicorn/asgi/message.py +++ b/gunicorn/asgi/message.py @@ -139,7 +139,7 @@ class AsyncRequest: async def _parse(self): """Parse the request from the unreader.""" buf = bytearray() - await self._read_into(buf, stop=True) + await self._read_into(buf) # Handle proxy protocol if enabled and this is the first request mode = self.cfg.proxy_protocol @@ -174,12 +174,10 @@ class AsyncRequest: self._set_body_reader() - async def _read_into(self, buf, stop=False): + async def _read_into(self, buf): """Read data from unreader and append to bytearray buffer.""" data = await self.unreader.read() if not data: - if stop: - raise StopIteration() raise NoMoreData(bytes(buf)) buf.extend(data) diff --git a/gunicorn/asgi/protocol.py b/gunicorn/asgi/protocol.py index 04320986..356bd507 100644 --- a/gunicorn/asgi/protocol.py +++ b/gunicorn/asgi/protocol.py @@ -186,9 +186,6 @@ class ASGIProtocol(asyncio.Protocol): peername, self.req_count ) - except StopIteration: - # No more data, close connection - break except NoMoreData: # Client disconnected break