'Assert that C{request} has forwarded a response from the server.
@param request: A L{DummyRequest}.
@param code: The expected HTTP response code.
@param message: The expected HTTP message.
@param headers: The expected HTTP headers.
@param body: The expected response body.'

def assertForwardsResponse(self, request, code, message, headers, body):

    self.assertEqual(request.responseCode, code)
    self.assertEqual(request.responseMessage, message)
    receivedHeaders = list(request.responseHeaders.getAllRawHeaders())
    receivedHeaders.sort()
    expectedHeaders = headers[:]
    expectedHeaders.sort()
    self.assertEqual(receivedHeaders, expectedHeaders)
    self.assertEqual(''.join(request.written), body)
