diff --git a/changelog.d/17036.misc b/changelog.d/17036.misc new file mode 100644 index 0000000000000000000000000000000000000000..32966680595215dc953fee7fea51af73fd320de0 --- /dev/null +++ b/changelog.d/17036.misc @@ -0,0 +1 @@ +Fix mypy with latest Twisted release. diff --git a/synapse/http/proxy.py b/synapse/http/proxy.py index 6cbbd5741ba17bcc8b1db558d25a21214437d75d..5b5ded757beb838e1131b01d1c083f39b3640878 100644 --- a/synapse/http/proxy.py +++ b/synapse/http/proxy.py @@ -262,7 +262,8 @@ class _ProxyResponseBody(protocol.Protocol): self._request.finish() else: # Abort the underlying request since our remote request also failed. - self._request.transport.abortConnection() + if self._request.channel: + self._request.channel.forceAbortClient() class ProxySite(Site): diff --git a/synapse/http/server.py b/synapse/http/server.py index 632284712c1dc2053e4637853d4f8d2c5d0b4bf8..c76500e14feb3b988ffa5f935bca02e6b918674f 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -153,9 +153,9 @@ def return_json_error( # Only respond with an error response if we haven't already started writing, # otherwise lets just kill the connection if request.startedWriting: - if request.transport: + if request.channel: try: - request.transport.abortConnection() + request.channel.forceAbortClient() except Exception: # abortConnection throws if the connection is already closed pass diff --git a/synapse/http/site.py b/synapse/http/site.py index 682b28e4c61869572520e47cd3683c5a2fc91dd3..a5b5780679ad2e1cd242337dbc25e8a58dbe80df 100644 --- a/synapse/http/site.py +++ b/synapse/http/site.py @@ -150,7 +150,8 @@ class SynapseRequest(Request): self.get_method(), self.get_redacted_uri(), ) - self.transport.abortConnection() + if self.channel: + self.channel.forceAbortClient() return super().handleContentChunk(data)