Ticket #22574: all-4xx-broken-links.patch

File all-4xx-broken-links.patch, 1.2 KB (added by Jon Dufresne, 11 years ago)

patch

  • django/middleware/common.py

    From 15bdc9788369c5fff63fde589fc9fcd0c41c23d3 Mon Sep 17 00:00:00 2001
    From: Jon Dufresne <jon.dufresne@gmail.com>
    Date: Sun, 4 May 2014 13:52:57 -0700
    Subject: [PATCH] Send broken link emails for all 4XX.
    
    This will allow manager to find links that incorrectly link to 403
    responses or pages with other 4xx responses. This goal is to root out
    these links and fix them.
    ---
     django/middleware/common.py | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/django/middleware/common.py b/django/middleware/common.py
    index c719f9e..112e564 100644
    a b class BrokenLinkEmailsMiddleware(object):  
    129129
    130130    def process_response(self, request, response):
    131131        """
    132         Send broken link emails for relevant 404 NOT FOUND responses.
     132        Send broken link emails for relevant 4XX responses.
    133133        """
    134         if response.status_code == 404 and not settings.DEBUG:
     134        if 400 <= response.status_code < 500 and not settings.DEBUG:
    135135            domain = request.get_host()
    136136            path = request.get_full_path()
    137137            referer = force_text(request.META.get('HTTP_REFERER', ''), errors='replace')
Back to Top