diff --git a/sanic/response.py b/sanic/response.py index ea233d9a..e5d5ccda 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -120,6 +120,9 @@ class StreamingHTTPResponse(BaseHTTPResponse): self.headers = headers or {} self._cookies = None + async def drain(): + await self.stream_writer.drain() + def write(self, data): """Writes a chunk of data to the streaming response. diff --git a/sanic/server.py b/sanic/server.py index f3106226..b998e13c 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -261,6 +261,7 @@ class HttpProtocol(asyncio.Protocol): try: keep_alive = self.keep_alive response.transport = self.transport + response.stream_writer = asyncio.StreamWriter(self.transport, self) await response.stream( self.request.version, keep_alive, self.request_timeout) if self.has_log: