'Returns the final response object.'

def finalize_response(self, request, response, *args, **kwargs):

    assert isinstance(response, HttpResponseBase), (u'Expected    a    `Response`,    `HttpResponse`    or    `HttpStreamingResponse`    to    be    returned    from    the    view,    but    received    a    `%s`' % type(response))
    if isinstance(response, Response):
        if (not getattr(request, u'accepted_renderer', None)):
            neg = self.perform_content_negotiation(request, force=True)
            (request.accepted_renderer, request.accepted_media_type) = neg
        response.accepted_renderer = request.accepted_renderer
        response.accepted_media_type = request.accepted_media_type
        response.renderer_context = self.get_renderer_context()
    vary_headers = self.headers.pop(u'Vary', None)
    if (vary_headers is not None):
        patch_vary_headers(response, cc_delim_re.split(vary_headers))
    for (key, value) in self.headers.items():
        response[key] = value
    return response
