twisted.web.httpView 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 _ChunkedTransferDecoder 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. -exarkun
|Instance Variable||dataCallback||A one-argument callable which will be invoked each time application data is received.|
|Instance Variable||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.|
|Instance Variable||length||Counter keeping track of how many more bytes in a chunk there are to receive.|
|Instance Variable||state||One of
|Method||dataReceived||Interpret data from a request or response body which uses the chunked Transfer-Encoding.|
|Method||noMoreData||Verify that all data has been received. If it has not been, raise
'CHUNK_LENGTH', data for the chunk length line is currently being read. For
'CRLF', the CR LF pair which follows each chunk is being read. For
'TRAILER', the CR LF pair which follows the terminal 0-length chunk is currently 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.
Interpret data from a request or response body which uses the chunked Transfer-Encoding.