Coverage for hookee/plugins/request_headers.py : 100.00%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from hookee.pluginmanager import REQUEST_PLUGIN
2from hookee.util import PrintUtil
4__author__ = "Alex Laird"
5__copyright__ = "Copyright 2020, Alex Laird"
6__version__ = "1.2.2"
8plugin_type = REQUEST_PLUGIN
9description = "Print the `request`'s headers, if defined."
11print_util = None # type: PrintUtil
14def setup(hookee_manager):
15 global print_util
17 print_util = hookee_manager.print_util
20def run(request):
21 if request.headers and "X-Forwarded-For" in request.headers:
22 print_util.print_basic("Client IP: {}".format(request.headers.get("X-Forwarded-For")),
23 color=print_util.request_color)
24 if request.headers:
25 print_util.print_dict("Headers", dict(request.headers), color=print_util.request_color)
27 return request