Ensure request method is compare to http_method_names of same case

Make sure both LHS and RHS are lower-cased in comparison for
membership testing.

Closes #8106
This commit is contained in:
Brad Solomon 2021-07-31 17:45:27 -04:00
parent 98e56e0327
commit 17539e6484

View File

@ -497,7 +497,7 @@ class APIView(View):
self.initial(request, *args, **kwargs) self.initial(request, *args, **kwargs)
# Get the appropriate handler method # Get the appropriate handler method
if request.method.lower() in self.http_method_names: if request.method.lower() in map(str.lower, self.http_method_names):
handler = getattr(self, request.method.lower(), handler = getattr(self, request.method.lower(),
self.http_method_not_allowed) self.http_method_not_allowed)
else: else: