From a727cca3c32b6b49262512b8a8eba64465bed25d Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 16 Sep 2016 21:43:39 +0300 Subject: [PATCH] Fix #1177: static file handling doesn't raise assertion anymore --- CHANGES.rst | 2 ++ aiohttp/file_sender.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 6e121ed983d..f658940f164 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,8 @@ CHANGES - Use `text/html` content type for displaying index pages by static file handler. +- Fix `AssertionError` in static file handling #1177 + 1.0.0 (09-16-2016) ------------------- diff --git a/aiohttp/file_sender.py b/aiohttp/file_sender.py index 197386f0562..d03cfaecc28 100644 --- a/aiohttp/file_sender.py +++ b/aiohttp/file_sender.py @@ -65,8 +65,21 @@ def _send_headers(resp_impl): pass resp._send_headers = _send_headers + + @asyncio.coroutine + def write_eof(): + # Durty hack required for + # https://github.com/KeepSafe/aiohttp/issues/1177 + # do nothing in write_eof + pass + + resp.write_eof = write_eof + yield from resp.prepare(request) + # TODO: %O and %b (resp_impl.output_length and resp_impl.output) + # access log formats are broken + loop = request.app.loop # See https://github.com/KeepSafe/aiohttp/issues/958 for details