def test_receiveResponseBeforeRequestGenerationDone(self):
        request = SlowRequest()
        d = self.protocol.request(request)
        self.protocol.dataReceived(
            "HTTP/1.1 200 OK\r\n"
            "X-Foo: bar\r\n"
            "Content-Length: 6\r\n"
            "\r\n"
            "foobar")
        def cbResponse(response):
            p = AccumulatingProtocol()
            whenFinished = p.closedDeferred = Deferred()
            response.deliverBody(p)
            return whenFinished.addCallback(
                lambda ign: (response, p.data))
        d.addCallback(cbResponse)
        def cbAllResponse((response, body)):
            self.assertEqual(response.version, ('HTTP', 1, 1))
            self.assertEqual(response.code, 200)
            self.assertEqual(response.phrase, 'OK')
            self.assertEqual(response.headers, Headers({'x-foo': ['bar']}))
            self.assertEqual(body, "foobar")

            # Also nothing bad should happen if the request does finally
            # finish, even though it is completely irrelevant.
            request.finished.callback(None)

        d.addCallback(cbAllResponse)
        return d
If response bytes are delivered to L{HTTP11ClientProtocol} before the
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/web/test/test_newclient.py/HTTP11ClientProtocolTests.test_receiveResponseBeforeRequestGenerationDone