mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 12:44:21 -04:00
Add a caching layer to .well-known responses (#4516)
This commit is contained in:
parent
3f189c902e
commit
bc5f6e1797
6 changed files with 493 additions and 10 deletions
|
@ -360,6 +360,7 @@ class FakeTransport(object):
|
|||
"""
|
||||
|
||||
disconnecting = False
|
||||
disconnected = False
|
||||
buffer = attr.ib(default=b'')
|
||||
producer = attr.ib(default=None)
|
||||
|
||||
|
@ -370,14 +371,16 @@ class FakeTransport(object):
|
|||
return None
|
||||
|
||||
def loseConnection(self, reason=None):
|
||||
logger.info("FakeTransport: loseConnection(%s)", reason)
|
||||
if not self.disconnecting:
|
||||
logger.info("FakeTransport: loseConnection(%s)", reason)
|
||||
self.disconnecting = True
|
||||
if self._protocol:
|
||||
self._protocol.connectionLost(reason)
|
||||
self.disconnected = True
|
||||
|
||||
def abortConnection(self):
|
||||
self.disconnecting = True
|
||||
logger.info("FakeTransport: abortConnection()")
|
||||
self.loseConnection()
|
||||
|
||||
def pauseProducing(self):
|
||||
if not self.producer:
|
||||
|
@ -416,9 +419,16 @@ class FakeTransport(object):
|
|||
# TLSMemoryBIOProtocol
|
||||
return
|
||||
|
||||
if self.disconnected:
|
||||
return
|
||||
logger.info("%s->%s: %s", self._protocol, self.other, self.buffer)
|
||||
|
||||
if getattr(self.other, "transport") is not None:
|
||||
self.other.dataReceived(self.buffer)
|
||||
self.buffer = b""
|
||||
try:
|
||||
self.other.dataReceived(self.buffer)
|
||||
self.buffer = b""
|
||||
except Exception as e:
|
||||
logger.warning("Exception writing to protocol: %s", e)
|
||||
return
|
||||
|
||||
self._reactor.callLater(0.0, _write)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue