From c055cf912d904f45703b423d9e1cd5954755f561 Mon Sep 17 00:00:00 2001 From: Adam Heinczinger Date: Wed, 14 Jun 2017 18:43:10 +0100 Subject: [PATCH] add drain method to StreamingHTTPResponse --- sanic/response.py | 3 +++ sanic/server.py | 1 + 2 files changed, 4 insertions(+) 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: