Go to the latest version of this document.
Part of twisted.protocols.amp
View In Hierarchy
A protocol for receving
es - key/value pairs - via
length-prefixed strings. A box is composed of:
any number of key-value pairs, described by:
a 2-byte network-endian packed key length (of which the first
byte must be null, and the second must be non-null: i.e. the value
of the length must be 1-255)
a key, comprised of that many bytes
a 2-byte network-endian unsigned value length (up to the maximum
a value, comprised of that many bytes
2 null bytes
In other words, an even number of strings prefixed with packed unsigned
16-bit integers, and then a 0-length string to indicate the end of the
This protocol also implements 2 extra private bits of functionality
related to the byte boundaries between messages; it can start TLS between
two given boxes or switch to an entirely different protocol. However, due
to some tricky elements of the implementation, the public interface to this
|Instance Variables||_keyLengthLimitExceeded||A flag which is only true when the connection is being closed because a
key length prefix which was longer than allowed by the protocol was
method will be invoked for each
Box that is received.
Switch this BinaryBoxProtocol's transport to a new protocol. You need
to do this 'simultaneously' on both ends of a connection; the easiest way
to do this is to use a subclass of ProtocolSwitchCommand.
|Parameters||newProto||the new protocol instance to switch to.
|clientFactory||the ClientFactory to send the |
Send a amp.Box to my peer.
Note: transport.write is never called outside of this method.
|Raises||ProtocolSwitched||if the protocol has previously been switched.
|ConnectionLost||if the connection has previously been lost.
that it is about to receive boxes from
this protocol by invoking
Either parse incoming data as
es or relay
it to our nested protocol.
The connection was lost; notify any nested protocol.
String received in the 'init' state.
String received in the 'key' state. If the key is empty, a complete box
has been received.
String received in the 'value' state.
The key length limit was exceeded. Disconnect the transport and make
sure a meaningful exception is reported.
Lock this binary protocol so that no further boxes may be sent. This is
used when sending a request to switch underlying protocols. You probably
want to subclass ProtocolSwitchCommand rather than calling this
Unlock this locked binary protocol so that further boxes may be sent
again. This is used after an attempt to switch protocols has failed for
Used by StartTLSCommand to put us into the state where we don't actually
send things that get sent, instead we buffer them. see
Used by TLSBox to initiate the SSL handshake.
The buck stops here. This error was completely unhandled, time to
terminate the connection.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:17:34.
The default TLS responder doesn't specify any certificate or
From a security perspective, it's little better than a plain-text
connection - but it is still a *bit* better, so it's included for
You probably want to override this by providing your own