Make HTTPS protocols work with the protocol switcher magic.

This commit is contained in:
Itamar Turner-Trauring 2022-07-20 15:25:22 -04:00
parent 11f4ebc0d9
commit 981b693402
1 changed files with 7 additions and 0 deletions

View File

@ -138,6 +138,13 @@ class _FoolscapOrHttps(Protocol, metaclass=_PretendToBeNegotiation):
protocol = self.https_factory.buildProtocol(self.transport.getPeer()) protocol = self.https_factory.buildProtocol(self.transport.getPeer())
protocol.makeConnection(self.transport) protocol.makeConnection(self.transport)
protocol.dataReceived(self._buffer) protocol.dataReceived(self._buffer)
# Update the factory so it knows we're transforming to a new
# protocol object (we'll do that next)
value = self.https_factory.protocols.pop(protocol)
self.https_factory.protocols[self] = value
# Transform self into the TLS protocol 🪄
self.__class__ = protocol.__class__ self.__class__ = protocol.__class__
self.__dict__ = protocol.__dict__ self.__dict__ = protocol.__dict__