From 825ce75faec63ce81601e31152c757a9c28fed13 Mon Sep 17 00:00:00 2001 From: Kevin Michel Date: Mon, 24 Aug 2020 22:25:33 +0200 Subject: Fixed #31928 -- Fixed detecting an async get_response in various middlewares. SecurityMiddleware and the three cache middlewares were not calling super().__init__() during their initialization or calling the required MiddlewareMixin._async_check() method. This made the middlewares not properly present as coroutine and confused the middleware chain when used in a fully async context. Thanks Kordian Kowalski for the report. --- django/middleware/security.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'django/middleware/security.py') diff --git a/django/middleware/security.py b/django/middleware/security.py index 035c329efb..44921cd22b 100644 --- a/django/middleware/security.py +++ b/django/middleware/security.py @@ -9,7 +9,7 @@ class SecurityMiddleware(MiddlewareMixin): # RemovedInDjango40Warning: when the deprecation ends, replace with: # def __init__(self, get_response): def __init__(self, get_response=None): - self._get_response_none_deprecation(get_response) + super().__init__(get_response) self.sts_seconds = settings.SECURE_HSTS_SECONDS self.sts_include_subdomains = settings.SECURE_HSTS_INCLUDE_SUBDOMAINS self.sts_preload = settings.SECURE_HSTS_PRELOAD @@ -19,7 +19,6 @@ class SecurityMiddleware(MiddlewareMixin): self.redirect_host = settings.SECURE_SSL_HOST self.redirect_exempt = [re.compile(r) for r in settings.SECURE_REDIRECT_EXEMPT] self.referrer_policy = settings.SECURE_REFERRER_POLICY - self.get_response = get_response def process_request(self, request): path = request.path.lstrip("/") -- cgit v1.3