Skip to content

Commit

Permalink
Refactor encoded_headers method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Nikitin committed Sep 8, 2023
1 parent c3b7dcd commit d573d5a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions silk/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,16 @@ def encoded_headers(self):
"""
From Django docs (https://docs.djangoproject.com/en/2.0/ref/request-response/#httprequest-objects):
"""
sensitive_headers = set(SilkyConfig().SILKY_SENSITIVE_KEYS)

sensitive_headers = set(map(str.lower, SilkyConfig().SILKY_SENSITIVE_KEYS))
sensitive_headers.add('authorization')
if SilkyConfig().SILKY_HIDE_COOKIES:
sensitive_headers.add('cookie')

sensitive_headers = set(map(str.lower, sensitive_headers))

headers = {}
for k, v in self.request.headers.items():
k = k.lower()
if k in sensitive_headers:
v = RequestModelFactory.CLEANSED_SUBSTITUTE

headers[k] = v

return json.dumps(headers, cls=DefaultEncoder, ensure_ascii=SilkyConfig().SILKY_JSON_ENSURE_ASCII)
Expand Down

0 comments on commit d573d5a

Please sign in to comment.