Skip to content

Commit a771567

Browse files
committed
Revert "Factor headers data out of HeaderDebugPanel."
This reverts commit 4326cbb.
1 parent f5769e4 commit a771567

File tree

2 files changed

+28
-39
lines changed

2 files changed

+28
-39
lines changed

debug_toolbar/debug/headers.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

debug_toolbar/panels/headers.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
from django.template.loader import render_to_string
22
from django.utils.translation import ugettext_lazy as _
33
from debug_toolbar.panels import DebugPanel
4-
from debug_toolbar.debug.headers import DebugHeaders
54

65
class HeaderDebugPanel(DebugPanel):
76
"""
87
A panel to display HTTP headers.
98
"""
109
name = 'Header'
1110
has_content = True
12-
13-
def __init__(self, context={}):
14-
super(HeaderDebugPanel, self).__init__(context)
15-
self.debug_headers = DebugHeaders()
11+
# List of headers we want to display
12+
header_filter = (
13+
'CONTENT_TYPE',
14+
'HTTP_ACCEPT',
15+
'HTTP_ACCEPT_CHARSET',
16+
'HTTP_ACCEPT_ENCODING',
17+
'HTTP_ACCEPT_LANGUAGE',
18+
'HTTP_CACHE_CONTROL',
19+
'HTTP_CONNECTION',
20+
'HTTP_HOST',
21+
'HTTP_KEEP_ALIVE',
22+
'HTTP_REFERER',
23+
'HTTP_USER_AGENT',
24+
'QUERY_STRING',
25+
'REMOTE_ADDR',
26+
'REMOTE_HOST',
27+
'REQUEST_METHOD',
28+
'SCRIPT_NAME',
29+
'SERVER_NAME',
30+
'SERVER_PORT',
31+
'SERVER_PROTOCOL',
32+
'SERVER_SOFTWARE',
33+
)
1634

1735
def nav_title(self):
1836
return _('HTTP Headers')
@@ -23,13 +41,14 @@ def title(self):
2341
def url(self):
2442
return ''
2543

44+
def process_request(self, request):
45+
self.headers = dict(
46+
[(k, request.META[k]) for k in self.header_filter if k in request.META]
47+
)
48+
2649
def content(self):
2750
context = self.context.copy()
2851
context.update({
2952
'headers': self.headers
3053
})
3154
return render_to_string('debug_toolbar/panels/headers.html', context)
32-
33-
def process_request(self, request):
34-
self.headers = self.debug_headers.available_headers(request)
35-

0 commit comments

Comments
 (0)