Browse Source

copy security headers to avoid the global varibale is updated

tags/v1.0.0
ougongchang 5 years ago
parent
commit
0e0082ef9c
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      mindinsight/backend/application.py

+ 4
- 3
mindinsight/backend/application.py View File

@@ -71,13 +71,14 @@ class CustomResponse(Response):
"""Define custom response."""
def __init__(self, response=None, **kwargs):
headers = kwargs.get("headers")
security_headers = list(SECURITY_HEADERS)
if isinstance(response, bytes):
mimetype = get_img_mimetype(response)
SECURITY_HEADERS.append(('Content-Type', mimetype))
security_headers.append(('Content-Type', mimetype))
if headers is None:
headers = Headers(SECURITY_HEADERS)
headers = Headers(security_headers)
else:
for header in SECURITY_HEADERS:
for header in security_headers:
headers.add(*header)
kwargs['headers'] = headers
super(CustomResponse, self).__init__(response, **kwargs)


Loading…
Cancel
Save