aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cramer2011-05-10 00:05:07 -0700
committerDavid Cramer2011-05-10 00:05:07 -0700
commit33a22a2e1200332b7e18a4ab4af6ef00e28d71dc (patch)
tree81808e6eabaac91e826783f3035e4adff1a37ff5
parent875a26213b9c623ddc90bfcf92f419ac8b45d007 (diff)
downloaddjango-debug-toolbar-33a22a2e1200332b7e18a4ab4af6ef00e28d71dc.tar.bz2
Catch non-200 requests (fixes #147)
-rw-r--r--debug_toolbar/middleware.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index b4619da..af46087 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -100,17 +100,18 @@ class DebugToolbarMiddleware(object):
toolbar = self.__class__.debug_toolbars.get(ident)
if not toolbar:
return response
- if toolbar.config['INTERCEPT_REDIRECTS']:
- if isinstance(response, HttpResponseRedirect):
- redirect_to = response.get('Location', None)
- if redirect_to:
- cookies = response.cookies
- response = render_to_response(
- 'debug_toolbar/redirect.html',
- {'redirect_to': redirect_to}
- )
- response.cookies = cookies
- if response.status_code == 200 and 'gzip' not in response.get('Content-Encoding', '') and \
+ if isinstance(response, HttpResponseRedirect):
+ if not toolbar.config['INTERCEPT_REDIRECTS']:
+ return response
+ redirect_to = response.get('Location', None)
+ if redirect_to:
+ cookies = response.cookies
+ response = render_to_response(
+ 'debug_toolbar/redirect.html',
+ {'redirect_to': redirect_to}
+ )
+ response.cookies = cookies
+ if 'gzip' not in response.get('Content-Encoding', '') and \
response.get('Content-Type', '').split(';')[0] in _HTML_TYPES:
for panel in toolbar.panels:
panel.process_response(request, response)