mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
Add IfMatchMissing exception
Needed to make testing easier.
This commit is contained in:
parent
cfd083d759
commit
a337dc3b5f
|
@ -96,6 +96,14 @@ class PreconditionFailed(APIException):
|
|||
self.detail = detail or self.default_detail
|
||||
|
||||
|
||||
class IfMatchMissing(APIException):
|
||||
default_detail = 'IF_MATCH header is required'
|
||||
status_code = 400
|
||||
|
||||
def __init__(self, detail=None):
|
||||
self.detail = detail or self.default_detail
|
||||
|
||||
|
||||
class ConfigurationError(Exception):
|
||||
"""
|
||||
Indicates an internal server error.
|
||||
|
|
|
@ -401,7 +401,7 @@ class APIView(View):
|
|||
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)
|
||||
raise exceptions.IfMatchMissing
|
||||
|
||||
response = handler(request, *args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user