aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug_toolbar/panels/headers.py10
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/headers.html23
-rw-r--r--docs/installation.rst7
-rw-r--r--docs/panels.rst11
-rw-r--r--example/settings.py2
5 files changed, 40 insertions, 13 deletions
diff --git a/debug_toolbar/panels/headers.py b/debug_toolbar/panels/headers.py
index de47c0e..38b5ac3 100644
--- a/debug_toolbar/panels/headers.py
+++ b/debug_toolbar/panels/headers.py
@@ -46,16 +46,18 @@ class HeaderDebugPanel(DebugPanel):
def process_request(self, request):
wsgi_env = list(sorted(request.META.items()))
- self.headers = OrderedDict(
+ self.request_headers = OrderedDict(
(unmangle(k), v) for (k, v) in wsgi_env if k.startswith('HTTP_'))
- if 'Cookie' in self.headers:
- self.headers['Cookie'] = '<< see Request Vars panel >>'
+ if 'Cookie' in self.request_headers:
+ self.request_headers['Cookie'] = '=> see Request Vars panel'
self.environ = OrderedDict(
(k, v) for (k, v) in wsgi_env if k in self.environ_filter)
def process_response(self, request, response):
+ self.response_headers = OrderedDict(sorted(response.items()))
self.record_stats({
- 'headers': self.headers,
+ 'request_headers': self.request_headers,
+ 'response_headers': self.response_headers,
'environ': self.environ,
})
diff --git a/debug_toolbar/templates/debug_toolbar/panels/headers.html b/debug_toolbar/templates/debug_toolbar/panels/headers.html
index 6b057e9..c7f01a2 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/headers.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/headers.html
@@ -1,6 +1,6 @@
{% load i18n %}
-<h4>{% trans "HTTP Headers" %}</h4>
+<h4>{% trans "Request Headers" %}</h4>
<table>
<thead>
@@ -10,7 +10,26 @@
</tr>
</thead>
<tbody>
- {% for key, value in headers.items %}
+ {% for key, value in request_headers.items %}
+ <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
+ <td>{{ key|escape }}</td>
+ <td>{{ value|escape }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+
+<h4>{% trans "Response Headers" %}</h4>
+
+<table>
+ <thead>
+ <tr>
+ <th>{% trans "Key" %}</th>
+ <th>{% trans "Value" %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for key, value in response_headers.items %}
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
<td>{{ key|escape }}</td>
<td>{{ value|escape }}</td>
diff --git a/docs/installation.rst b/docs/installation.rst
index 1e228cb..32483df 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -28,9 +28,10 @@ Installation
Tying into middleware allows each panel to be instantiated on request and
rendering to happen on response.
- The order of ``MIDDLEWARE_CLASSES`` is important: the Debug Toolbar
- middleware must come after any other middleware that encodes the
- response's content (such as GZipMiddleware).
+ The order of ``MIDDLEWARE_CLASSES`` is important. You should include the
+ Debug Toolbar middleware as early as possible in the list. However, it must
+ come after any other middleware that encodes the response's content, such
+ as ``GZipMiddleware``.
.. note::
diff --git a/docs/panels.rst b/docs/panels.rst
index a4b809e..b5b7b2e 100644
--- a/docs/panels.rst
+++ b/docs/panels.rst
@@ -30,12 +30,17 @@ Path: ``debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel``
A list of settings in settings.py.
-Header
-~~~~~~
+Headers
+~~~~~~~
Path: ``debug_toolbar.panels.headers.HeaderDebugPanel``
-Common HTTP headers.
+This panels shows the HTTP request and response headers, as well as a
+selection of values from the WSGI environment.
+
+Note that headers set by middleware placed before the debug toolbar middleware
+in ``MIDDLEWARE_CLASSES`` won't be visible in the panel. The WSGI server
+itself may also add response headers such as ``Date`` and ``Server``.
Request
~~~~~~~
diff --git a/example/settings.py b/example/settings.py
index 4df22a0..ce1f8e2 100644
--- a/example/settings.py
+++ b/example/settings.py
@@ -28,13 +28,13 @@ INSTALLED_APPS = (
)
MIDDLEWARE_CLASSES = (
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'example.urls'