'Send broken link emails and calculate the Etag, if needed.'

def process_response(self, request, response):

    if (response.status_code == 404):
        if (settings.SEND_BROKEN_LINK_EMAILS and (not settings.DEBUG)):
            domain = request.get_host()
            referer = request.META.get('HTTP_REFERER', None)
            is_internal = _is_internal_request(domain, referer)
            path = request.get_full_path()
            if (referer and (not _is_ignorable_404(path)) and (is_internal or ('?' not in referer))):
                ua = request.META.get('HTTP_USER_AGENT', '<none>')
                ip = request.META.get('REMOTE_ADDR', '<none>')
                mail_managers(('Broken    %slink    on    %s' % (((is_internal and 'INTERNAL    ') or ''), domain)), ('Referrer:    %s\nRequested    URL:    %s\nUser    agent:    %s\nIP    address:    %s\n' % (referer, request.get_full_path(), ua, ip)), fail_silently=True)
            return response
    if settings.USE_ETAGS:
        if response.has_header('ETag'):
            etag = response['ETag']
        elif response.streaming:
            etag = None
        else:
            etag = ('"%s"' % hashlib.md5(response.content).hexdigest())
        if (etag is not None):
            if ((200 <= response.status_code < 300) and (request.META.get('HTTP_IF_NONE_MATCH') == etag)):
                cookies = response.cookies
                response = http.HttpResponseNotModified()
                response.cookies = cookies
            else:
                response['ETag'] = etag
    return response
