Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
More forcefully close the connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 16, 2021
1 parent 0be5ce4 commit fb54d3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@ def dataReceived(self, data: bytes) -> None:
# in the meantime.
if self.max_size is not None and self.length >= self.max_size:
self.deferred.errback(BodyExceededMaxSize())
self.transport.loseConnection()
# Close the connection (forcefully) since all the data will get
# discarded anyway.
self.transport.abortConnection()

def connectionLost(self, reason: Failure) -> None:
# If the maximum size was already exceeded, there's nothing to do.
Expand Down
2 changes: 1 addition & 1 deletion tests/http/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_additional_data(self):
self.protocol.dataReceived(b"1234567890")
self.assertIsInstance(self.deferred.result, Failure)
self.assertIsInstance(self.deferred.result.value, BodyExceededMaxSize)
self.protocol.transport.loseConnection.assert_called_once()
self.protocol.transport.abortConnection.assert_called_once()

# More data might have come in.
self.protocol.dataReceived(b"1234567890")
Expand Down

0 comments on commit fb54d3c

Please sign in to comment.