Part of twisted.web.http View Source View In Hierarchy
Protocol for decoding chunked Transfer-Encoding, as defined by RFC 2616, section 3.6.1. This protocol can interpret the contents of a request or response body which uses the chunked Transfer-Encoding. It cannot interpret any of the rest of the HTTP protocol.
It may make sense for _ChunkedTransferEncoding to be an actual IProtocol implementation. Currently, the only user of this class will only ever call dataReceived on it. However, it might be an improvement if the user could connect this to a transport and deliver connection lost notification. This way, `dataCallback` becomes `self.transport.write` and perhaps `finishCallback` becomes `self.transport.loseConnection()` (although I'm not sure where the extra data goes in that case). This could also allow this object to indicate to the receiver of data that the stream was not completely received, an error case which should be noticed. -exarkunInstance Variables | dataCallback | A one-argument callable which will be invoked each time application data is received. |
finishCallback | A one-argument callable which will be invoked when the terminal chunk is received. It will be invoked with all bytes which were delivered to this protocol which came after the terminal chunk. | |
length | Counter keeping track of how many more bytes in a chunk there are to receive. | |
state | One of 'chunk-length' , 'trailer' ,
'body' , or 'finished' . For
'chunk-length' , data for the chunk length line is currently
being read. For 'trailer' , the CR LF pair which follows each
chunk is being read. For 'body' , the contents of a chunk are
being read. For 'finished' , the last chunk has been
completely read and no more input is valid.
| |
finish | A flag indicating that the last chunk has been started. When it
finishes, the state will change to 'finished' and no more data
will be accepted.
|
Method | __init__ | Undocumented |
Method | dataReceived | Interpret data from a request or response body which uses the chunked Transfer-Encoding. |