.title() all header keys (rest_api.py)

This commit is contained in:
jesopo 2018-12-06 12:00:45 +00:00
parent bae1fac147
commit e6b0d4d167

View file

@ -14,6 +14,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
_, _, endpoint = path[1:].partition("/") _, _, endpoint = path[1:].partition("/")
endpoint, _, args = endpoint.partition("/") endpoint, _, args = endpoint.partition("/")
args = list(filter(None, args.split("/"))) args = list(filter(None, args.split("/")))
headers = {key.title(): value for key, value in self.headers}
response = "" response = ""
code = 404 code = 404
@ -33,7 +34,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
event_response = _bot.trigger(lambda: event_response = _bot.trigger(lambda:
_events.on("api").on(method).on( _events.on("api").on(method).on(
endpoint).call_unsafe_for_result(params=params, endpoint).call_unsafe_for_result(params=params,
path=args, data=data, headers=dict(self.headers))) path=args, data=data, headers=headers))
except Exception as e: except Exception as e:
_log.error("failed to call API endpoint \"%s\"", _log.error("failed to call API endpoint \"%s\"",
[path], exc_info=True) [path], exc_info=True)