Switch to using a case insensitive dictionary for headers instead of doing
.title() on each header key
This commit is contained in:
parent
281923a463
commit
9bef4b7df1
3 changed files with 10 additions and 2 deletions
|
@ -41,7 +41,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
)["payload"][0]
|
)["payload"][0]
|
||||||
data = json.loads(payload)
|
data = json.loads(payload)
|
||||||
|
|
||||||
github_event = event["headers"]["X-Github-Event"]
|
github_event = event["headers"]["X-GitHub-Event"]
|
||||||
if github_event == "ping":
|
if github_event == "ping":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -14,7 +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.items()}
|
headers = utils.CaseInsensitiveDict(dict(self.headers.items()))
|
||||||
|
|
||||||
response = ""
|
response = ""
|
||||||
code = 404
|
code = 404
|
||||||
|
|
|
@ -171,3 +171,11 @@ def top_10(items: typing.Dict[typing.Any, typing.Any],
|
||||||
value_format(items[key])))
|
value_format(items[key])))
|
||||||
|
|
||||||
return top_10_items
|
return top_10_items
|
||||||
|
|
||||||
|
class CaseInsensitiveDict(dict):
|
||||||
|
def __init__(self, other):
|
||||||
|
dict.__init__(self, ((k.lower(), v) for k, v in other))
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return dict.__getitem__(self, key.lower())
|
||||||
|
def __setitem__(self, key):
|
||||||
|
return dict.__setitem__(self, key.lower())
|
||||||
|
|
Loading…
Reference in a new issue