'Interpret the next chunk of bytes received.  Either deliver them to the
data callback or invoke the finish callback if enough bytes have been
received.
@raise RuntimeError: If the finish callback has already been invoked
during a previous call to this methood.'

def dataReceived(self, data):

    if (self.dataCallback is None):
        raise RuntimeError('_IdentityTransferDecoder    cannot    decode    data    after    finishing')
    if (self.contentLength is None):
        self.dataCallback(data)
    elif (len(data) < self.contentLength):
        self.contentLength -= len(data)
        self.dataCallback(data)
    else:
        contentLength = self.contentLength
        dataCallback = self.dataCallback
        finishCallback = self.finishCallback
        self.dataCallback = self.finishCallback = None
        self.contentLength = 0
        dataCallback(data[:contentLength])
        finishCallback(data[contentLength:])
