'If L{Request} is created with a C{bodyProducer} without a known length
and the L{Deferred} returned from its C{startProducing} method fires
with a L{Failure}, the L{Deferred} returned by L{Request.writeTo} fires
with that L{Failure} and the body producer is unregistered from the
transport.  The final zero-length chunk is not written to the
transport.'

def test_sendChunkedRequestBodyWithError(self):

    producer = StringProducer(UNKNOWN_LENGTH)
    request = Request('POST', '/bar', _boringHeaders, producer)
    writeDeferred = request.writeTo(self.transport)
    self.transport.clear()
    producer.finished.errback(ArbitraryException())
    def cbFailed(ignored):
        self.assertEqual(self.transport.value(), '')
        self.assertIdentical(self.transport.producer, None)
    d = self.assertFailure(writeDeferred, ArbitraryException)
    d.addCallback(cbFailed)
    return d
