mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
Switch to a view level setting for using etags
* Check for existance of `use_etags` as a precondition. * Set etag_header irregardless of the HTTP_IF_MATCH header state.
This commit is contained in:
parent
53ca0c02b0
commit
bceca2364a
|
@ -398,12 +398,10 @@ class APIView(View):
|
|||
else:
|
||||
handler = self.http_method_not_allowed
|
||||
|
||||
if self.use_etags and request.method.lower() in ('put', 'delete'):
|
||||
etag_header = request.META.get('HTTP_IF_MATCH')
|
||||
if etag_header is None:
|
||||
return Response({'error': 'IF_MATCH header is required'}, status=400)
|
||||
else:
|
||||
self.etag_header = etag_header
|
||||
if getattr(self, 'use_etags', False) and request.method.lower() in ('put', 'delete'):
|
||||
self.etag_header = request.META.get('HTTP_IF_MATCH')
|
||||
if self.etag_header is None:
|
||||
return Response({'detail': 'IF_MATCH header is required'}, status=400, exception=True)
|
||||
|
||||
response = handler(request, *args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user