Skip to content

Commit

Permalink
Remove heartbeat on closing connection on keepalive timeout (#3041)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Jun 1, 2018
1 parent e021a01 commit 52d7e3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES/3041.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove heartbeat on closing connection on keepalive timeout.
The used hack violates HTTP protocol.
6 changes: 2 additions & 4 deletions aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down

0 comments on commit 52d7e3a

Please sign in to comment.