add drain method to StreamingHTTPResponse

This commit is contained in:
Adam Heinczinger 2017-06-14 18:43:10 +01:00
parent df47cf72d3
commit c055cf912d
2 changed files with 4 additions and 0 deletions

View File

@ -120,6 +120,9 @@ class StreamingHTTPResponse(BaseHTTPResponse):
self.headers = headers or {} self.headers = headers or {}
self._cookies = None self._cookies = None
async def drain():
await self.stream_writer.drain()
def write(self, data): def write(self, data):
"""Writes a chunk of data to the streaming response. """Writes a chunk of data to the streaming response.

View File

@ -261,6 +261,7 @@ class HttpProtocol(asyncio.Protocol):
try: try:
keep_alive = self.keep_alive keep_alive = self.keep_alive
response.transport = self.transport response.transport = self.transport
response.stream_writer = asyncio.StreamWriter(self.transport, self)
await response.stream( await response.stream(
self.request.version, keep_alive, self.request_timeout) self.request.version, keep_alive, self.request_timeout)
if self.has_log: if self.has_log: