diff --git a/tornado/http1connection.py b/tornado/http1connection.py index ca50e8ff55..86d73b88f6 100644 --- a/tornado/http1connection.py +++ b/tornado/http1connection.py @@ -700,13 +700,13 @@ async def _read_chunked_body(self, delegate: httputil.HTTPMessageDelegate) -> No async def _read_body_until_close( self, delegate: httputil.HTTPMessageDelegate ) -> None: - body = await self.stream.read_until_close() - if not self._write_finished or self.is_client: - with _ExceptionLoggingContext(app_log): - ret = delegate.data_received(body) - if ret is not None: - await ret - + while True: + chunk = await self.stream.read_bytes(self.params.chunk_size, partial=True) + if not self._write_finished or self.is_client: + with _ExceptionLoggingContext(app_log): + ret = delegate.data_received(chunk) + if ret is not None: + await ret class _GzipMessageDelegate(httputil.HTTPMessageDelegate): """Wraps an `HTTPMessageDelegate` to decode ``Content-Encoding: gzip``."""