From 0e0082ef9c400b1f93a5655bf6b23463d7253eb9 Mon Sep 17 00:00:00 2001 From: ougongchang Date: Thu, 17 Sep 2020 15:38:47 +0800 Subject: [PATCH] copy security headers to avoid the global varibale is updated --- mindinsight/backend/application.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mindinsight/backend/application.py b/mindinsight/backend/application.py index b9f63b0c..73b941f1 100644 --- a/mindinsight/backend/application.py +++ b/mindinsight/backend/application.py @@ -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)