mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 01:20:02 +03:00
Dont' require IF_MATCH header
The HTTP RFC doesn't require the IF_MATCH header and it's language on what to do when it's not included isn't absolute so removing this check. The implementing codebase can easily add this by overriding precondition_check in ETagCacheLookup if necessary.
This commit is contained in:
parent
879302c815
commit
2139c109ab
|
@ -96,14 +96,6 @@ class PreconditionFailed(APIException):
|
|||
self.detail = detail or self.default_detail
|
||||
|
||||
|
||||
class IfMatchMissing(APIException):
|
||||
default_detail = 'IF_MATCH header is required'
|
||||
status_code = status.HTTP_400_BAD_REQUEST
|
||||
|
||||
def __init__(self, detail=None):
|
||||
self.detail = detail or self.default_detail
|
||||
|
||||
|
||||
class ConfigurationError(Exception):
|
||||
"""
|
||||
Indicates an internal server error.
|
||||
|
|
|
@ -313,15 +313,6 @@ class APIView(View):
|
|||
headers.update(cache_lookup.get_response_header(obj))
|
||||
return headers
|
||||
|
||||
def check_update_validity(self, request):
|
||||
"""
|
||||
"""
|
||||
# TODO add setting to cover
|
||||
# * raise IfMatchMissing when it's missing (if it's there, carry on)
|
||||
# * continue regardless
|
||||
if request.META.get('HTTP_IF_MATCH') is None:
|
||||
raise exceptions.IfMatchMissing
|
||||
|
||||
def cache_precondition_check(self, obj, request):
|
||||
for cache_lookup in self.get_cache_lookups():
|
||||
cache_lookup.precondition_check(obj, request)
|
||||
|
@ -430,10 +421,6 @@ class APIView(View):
|
|||
else:
|
||||
handler = self.http_method_not_allowed
|
||||
|
||||
if request.method.lower() in ('put', 'delete'):
|
||||
# FIXME this method name isn't obvious
|
||||
self.check_update_validity(request)
|
||||
|
||||
response = handler(request, *args, **kwargs)
|
||||
|
||||
except Exception as exc:
|
||||
|
|
Loading…
Reference in New Issue
Block a user