'When the connection is aborted after the response headers have
been received and the L{Response} has been made available to
application code, the response body protocol\'s C{connectionLost}
method will be invoked with a L{ResponseFailed} failure containing a
L{ConnectionAborted} exception.'

def test_abortAfterResponseHeaders(self):

    transport = StringTransport(lenient=True)
    protocol = HTTP11ClientProtocol()
    protocol.makeConnection(transport)
    result = protocol.request(Request('GET', '/', _boringHeaders, None))
    protocol.dataReceived('HTTP/1.1    200    OK\r\nContent-Length:    1\r\n\r\n')
    testResult = Deferred()
    class BodyDestination(Protocol, ):
        '\n                                                A    body    response    protocol    which    immediately    aborts    the    HTTP\n                                                connection.\n                                                '
        def connectionMade(self):
            '\n                                                                Abort    the    HTTP    connection.\n                                                                '
            protocol.abort()
        def connectionLost(self, reason):
            '\n                                                                Make    the    reason    for    the    losing    of    the    connection    available    to\n                                                                the    unit    test    via    C{testResult}.\n                                                                '
            testResult.errback(reason)
    def deliverBody(response):
        '\n                                                Connect    the    L{BodyDestination}    response    body    protocol    to    the\n                                                response,    and    then    simulate    connection    loss    after    ensuring    that\n                                                the    HTTP    connection    has    been    aborted.\n                                                '
        response.deliverBody(BodyDestination())
        self.assertTrue(transport.disconnecting)
        protocol.connectionLost(Failure(ConnectionDone()))
    def checkError(error):
        self.assertIsInstance(error.response, Response)
    result.addCallback(deliverBody)
    deferred = assertResponseFailed(self, testResult, [ConnectionAborted, _DataLoss])
    return deferred.addCallback(checkError)
