'The L{Deferred} returned by L{HTTP11ClientProtocol.request} will fire
with a L{RequestGenerationFailed} failure containing a
L{CancelledError} exception if the request was cancelled before a
C{bodyProducer} has finished producing.'

def assertCancelDuringBodyProduction(self, producerLength):

    transport = StringTransport()
    protocol = HTTP11ClientProtocol()
    protocol.makeConnection(transport)
    producer = StringProducer(producerLength)
    nonLocal = {'cancelled': False}
    def cancel(ign):
        nonLocal['cancelled'] = True
    def startProducing(consumer):
        producer.consumer = consumer
        producer.finished = Deferred(cancel)
        return producer.finished
    producer.startProducing = startProducing
    result = protocol.request(Request('POST', '/bar', _boringHeaders, producer))
    producer.consumer.write(('x' * 5))
    result.cancel()
    self.assertTrue(transport.aborting)
    self.assertTrue(nonLocal['cancelled'])
    return assertRequestGenerationFailed(self, result, [CancelledError])
