'Returns an HttpResponse object for the given HttpRequest'

def get_response(self, request):

    from django.core import exceptions, urlresolvers
    from django.conf import settings
    try:
        urlconf = settings.ROOT_URLCONF
        urlresolvers.set_urlconf(urlconf)
        resolver = urlresolvers.RegexURLResolver('^/', urlconf)
        for middleware_method in self._request_middleware:
            response = middleware_method(request)
            if response:
                return response
        if hasattr(request, 'urlconf'):
            urlconf = request.urlconf
            urlresolvers.set_urlconf(urlconf)
            resolver = urlresolvers.RegexURLResolver('^/', urlconf)
        (callback, callback_args, callback_kwargs) = resolver.resolve(request.path_info)
        for middleware_method in self._view_middleware:
            response = middleware_method(request, callback, callback_args, callback_kwargs)
            if response:
                return response
        try:
            response = callback(request, *callback_args, **callback_kwargs)
        except Exception as e:
            for middleware_method in self._exception_middleware:
                response = middleware_method(request, e)
                if response:
                    return response
            raise
        if (response is None):
            try:
                view_name = callback.func_name
            except AttributeError:
                view_name = (callback.__class__.__name__ + '.__call__')
            raise ValueError(("The    view    %s.%s    didn't    return    an    HttpResponse    object." % (callback.__module__, view_name)))
        return response
    except http.Http404 as e:
        if settings.DEBUG:
            from django.views import debug
            return debug.technical_404_response(request, e)
        else:
            try:
                (callback, param_dict) = resolver.resolve404()
                return callback(request, **param_dict)
            except:
                try:
                    return self.handle_uncaught_exception(request, resolver, sys.exc_info())
                finally:
                    receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
    except exceptions.PermissionDenied:
        return http.HttpResponseForbidden('<h1>Permission    denied</h1>')
    except SystemExit:
        raise
    except:
        receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
        return self.handle_uncaught_exception(request, resolver, sys.exc_info())
    finally:
        urlresolvers.set_urlconf(None)
