diff options
| author | Rob Hudson | 2008-09-07 11:03:22 -0700 |
|---|---|---|
| committer | Rob Hudson | 2008-09-07 11:03:22 -0700 |
| commit | 571a5196ef049cc1a948370753528a864653a7c0 (patch) | |
| tree | 21a84c2a5758cbfd884a211c376734f19a398fd9 /debug_toolbar/panels/headers.py | |
| parent | 6a1e15b3c9f5658a26b77121af126a84258f8b0d (diff) | |
| download | django-debug-toolbar-571a5196ef049cc1a948370753528a864653a7c0.tar.bz2 | |
Adding a new panel to display HTTP headers
Diffstat (limited to 'debug_toolbar/panels/headers.py')
| -rw-r--r-- | debug_toolbar/panels/headers.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/debug_toolbar/panels/headers.py b/debug_toolbar/panels/headers.py new file mode 100644 index 0000000..ab39b85 --- /dev/null +++ b/debug_toolbar/panels/headers.py @@ -0,0 +1,52 @@ +from django.template import Context, Template +from debug_toolbar.panels import DebugPanel + +class HeaderDebugPanel(DebugPanel): + """ + A panel to display HTTP headers. + """ + name = 'Header' + # List of headers we want to display + header_filter = [ + 'CONTENT_TYPE', + 'HTTP_ACCEPT', + 'HTTP_ACCEPT_CHARSET', + 'HTTP_ACCEPT_ENCODING', + 'HTTP_ACCEPT_LANGUAGE', + 'HTTP_CACHE_CONTROL', + 'HTTP_CONNECTION', + 'HTTP_HOST', + 'HTTP_KEEP_ALIVE', + 'HTTP_REFERER', + 'HTTP_USER_AGENT', + 'QUERY_STRING', + 'REMOTE_ADDR', + 'REMOTE_HOST', + 'REQUEST_METHOD', + 'SCRIPT_NAME', + 'SERVER_NAME', + 'SERVER_PORT', + 'SERVER_PROTOCOL', + 'SERVER_SOFTWARE', + ] + def title(self): + return 'HTTP Headers' + + def url(self): + return '' + + def content(self): + t = Template(''' + <dl> + {% for h in headers %} + <dt><strong>{{ h.key }}</strong></dt> + <dd>{{ h.value }}</dd> + {% endfor %} + </dl> + ''') + headers = [] + for k, v in self.request.META.iteritems(): + if k in self.header_filter: + headers.append({'key': k, 'value': v}) + c = Context({'headers': headers}) + return t.render(c) |
