1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-27 18:17:46 +00:00
bazarr/libs/flask_debugtoolbar/panels/headers.py

57 lines
1.3 KiB
Python
Raw Normal View History

2019-12-16 13:58:10 +00:00
from flask_debugtoolbar.panels import DebugPanel
_ = lambda x: x
class HeaderDebugPanel(DebugPanel):
"""
A panel to display HTTP headers.
"""
name = 'Header'
has_content = True
# 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 nav_title(self):
return _('HTTP Headers')
def title(self):
return _('HTTP Headers')
def url(self):
return ''
def process_request(self, request):
self.headers = dict(
[(k, request.environ[k])
for k in self.header_filter if k in request.environ]
)
def content(self):
context = self.context.copy()
context.update({
'headers': self.headers
})
return self.render('panels/headers.html', context)