def _testDataForward(self, code, message, headers, body, method=b"GET",
                         requestBody=b"", loseConnection=True):
        """
        Build a fake proxy connection, and send C{data} over it, checking that
        it's forwarded to the originating request.
        """
        request = self.makeRequest(b'foo')
        client = self.makeProxyClient(
            request, method, {b'accept': b'text/html'}, requestBody)

        receivedBody = self.assertForwardsHeaders(
            client, method + b' /foo HTTP/1.0',
            {b'connection': b'close', b'accept': b'text/html'})

        self.assertEqual(receivedBody, requestBody)

        # Fake an answer
        client.dataReceived(
            self.makeResponseBytes(code, message, headers, body))

        # Check that the response data has been forwarded back to the original
        # requester.
        self.assertForwardsResponse(request, code, message, headers, body)

        # Check that when the response is done, the request is finished.
        if loseConnection:
            client.transport.loseConnection()

        # Even if we didn't call loseConnection, the transport should be
        # disconnected.  This lets us not rely on the server to close our
        # sockets for us.
        self.assertFalse(client.transport.connected)
        self.assertEqual(request.finished, 1)

        Build a fake proxy connection, and send C{data} over it, checking that
        it's forwarded to the originating request.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_proxy.py