#3204 enhancement new
provide a clean access mechanism to access and switch protocols from an ITransport provider
|Reported by:||Glyph||Owned by:||Itamar Turner-Trauring|
|Cc:||davidsarah, Adi Roiban, Daniele Ricci||Branch:||
branch-diff, diff-cov, branch-cov, buildbot
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.
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.