[Twisted-Python] Switching Protocols and TLS

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Aug 29 09:53:01 EDT 2012

On 01:19 pm, tobias.oberstein at tavendo.de wrote:
>I am running a Twisted Web Site object that switches the protocol for 
>specific paths.
>The goal is to run Twisted Web, and have certain paths mapped to 
>I am aware of
>but in the meantime have working code
>This works for non-TLS, but not for TLS.
>This works perfectly:
>and this does NOT work:
>The latter is able to send stuff down to client, but won't receive 
>Any hint how to track that down would be great!

The `protocol´ attribute isn't part of the transport interface.  Some 
transports are implemented in a way such that changing that attribute to 
refer to a different protocol will produce the behavior you're after, 
but not all.  In particular, the transport implemented in 
twisted.protocols.tls (used to provide the transport whenever you use 
listenSSL, connectSSL, or startTLS) does not work this way.

You should be able to work out which attribute needs to be mangled by 
looking at twisted/protocols/tls.py.  My initial guess would be 
`wrappedProtocol`, but that's *only* a guess.  And of course, whatever 
you find is not going to be part of any formal transport interface 
either, so it's not guaranteed to keep working in the future, or to work 
with any other transport you might end up using - hence the desire to 
resolve #3204.


More information about the Twisted-Python mailing list