From 9cf871e79365e0a17bb7829fea81649dfb88830e Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 31 May 2018 15:45:45 +0300 Subject: [PATCH 1/2] Remove heartbeat on closing connection on keepalive timeout --- aiohttp/web_protocol.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py index 73a2c3f14e5..ecd1414a6ae 100644 --- a/aiohttp/web_protocol.py +++ b/aiohttp/web_protocol.py @@ -286,14 +286,12 @@ def close(self): if self._waiter: self._waiter.cancel() - def force_close(self, send_last_heartbeat=False): + def force_close(self): """Force close connection""" self._force_close = True if self._waiter: self._waiter.cancel() if self.transport is not None: - if send_last_heartbeat: - self.transport.write(b"\r\n") self.transport.close() self.transport = None @@ -317,7 +315,7 @@ def _process_keepalive(self): # handler in idle state if self._waiter: if self._loop.time() > next: - self.force_close(send_last_heartbeat=True) + self.force_close() return # not all request handlers are done, From f361c7a8a76e0127c2ef90162a2a06ab75f2e33e Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 31 May 2018 15:48:45 +0300 Subject: [PATCH 2/2] Add changelog --- CHANGES/3041.feature | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CHANGES/3041.feature diff --git a/CHANGES/3041.feature b/CHANGES/3041.feature new file mode 100644 index 00000000000..028d3b6b2d2 --- /dev/null +++ b/CHANGES/3041.feature @@ -0,0 +1,2 @@ +Remove heartbeat on closing connection on keepalive timeout. +The used hack violates HTTP protocol.