'If L{HTTP11ClientProtocol}\'s transport is disconnected before the
L{Deferred} returned by L{Request.writeTo} fires, the L{Deferred}
returned by L{HTTP11ClientProtocol.request} fires with a L{Failure} of
L{RequestTransmissionFailed} wrapping the underlying failure.'

def test_connectionLostDuringRequestGeneration(self, mode=None):

    request = SlowRequest()
    d = self.protocol.request(request)
    d = assertRequestTransmissionFailed(self, d, [ArbitraryException])
    self.assertFalse(request.stopped)
    self.protocol.connectionLost(Failure(ArbitraryException()))
    self.assertTrue(request.stopped)
    if (mode == 'callback'):
        request.finished.callback(None)
    elif (mode == 'errback'):
        request.finished.errback(Failure(AnotherArbitraryException()))
        errors = self.flushLoggedErrors(AnotherArbitraryException)
        self.assertEqual(len(errors), 1)
    else:
        pass
    return d
