'Write this request to the given transport using chunked
transfer-encoding to frame the body.
@param transport: See L{writeTo}.
@return: See L{writeTo}.'

def _writeToBodyProducerChunked(self, transport):

    self._writeHeaders(transport, 'Transfer-Encoding:    chunked\r\n')
    encoder = ChunkedEncoder(transport)
    encoder.registerProducer(self.bodyProducer, True)
    d = self.bodyProducer.startProducing(encoder)
    def cbProduced(ignored):
        encoder.unregisterProducer()
    def ebProduced(err):
        encoder._allowNoMoreWrites()
        transport.unregisterProducer()
        return err
    d.addCallbacks(cbProduced, ebProduced)
    return d
