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. 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,