Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove heartbeat on closing connection on keepalive timeout #3041

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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