#3204 enhancement new
provide a clean access mechanism to access and switch protocols from an ITransport provider
|Reported by:||glyph||Owned by:||itamar|
(diff, github, buildbot, log)
Some protocols - such as any protocol with a "STARTTLS" command - allow you to switch to a different application-level protocol in the middle of a connection.
Currently, Twisted contains two kinds of hacks to make this happen. One, as in TLS support, gets into the guts of the reactor implementation to allow you to switch protocols. Another, as in AMP's protocol switch command, adds an additional layer of (inefficient, overcomplex) wrapping in order to connect a different protocol to the available transport.
Currently, tcp.Connection happens to have a protocol attribute, but this is a mostly undocumented accident; it would be good to have an explicit API to switch protocols associated with ITransport.
I don't have a specific use-case at the moment for accessing the protocol attribute, but it seems like it would be nice to provide access along with mutation.