File: //usr/lib/python3/dist-packages/django/views/decorators/__pycache__/http.cpython-310.pyc
o
3�ay � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZ ee�Zd
d� Zedg�Zd
e_ edg�Zde_ eddg�Zde_ ddd�Zdd� Zdd� ZdS )z-
Decorators for views based on HTTP headers.
� )�timegm��wraps)�HttpResponseNotAllowed)�ConditionalGetMiddleware)�get_conditional_response)�decorator_from_middleware)� http_date�
quote_etag)�log_responsec s � fdd�}|S )a9
Decorator to make a view only accept particular request methods. Usage::
@require_http_methods(["GET", "POST"])
def my_view(request):
# I can assume now that only GET or POST requests make it this far
# ...
Note that request methods should be in uppercase.
c s t � �� �fdd��}|S )Nc sB | j �vrt��}td| j | j|| d� |S � | g|�R i |��S )NzMethod Not Allowed (%s): %s)�response�request)�methodr r �path)r
�args�kwargsr )�func�request_method_list� �>/usr/lib/python3/dist-packages/django/views/decorators/http.py�inner s
�z6require_http_methods.<locals>.decorator.<locals>.innerr �r r �r �r r � decorator s
z'require_http_methods.<locals>.decoratorr )r r r r r �require_http_methods s
r �GETz=Decorator to require that a view only accepts the GET method.�POSTz>Decorator to require that a view only accepts the POST method.�HEADzIDecorator to require that a view only accepts safe methods: GET and HEAD.Nc s � �fdd�}|S )ak
Decorator to support conditional retrieval (or change) for a view
function.
The parameters are callables to compute the ETag and last modified time for
the requested resource, respectively. The callables are passed the same
parameters as the view itself. The ETag function should return a string (or
None if the resource doesn't exist), while the last_modified function
should return a datetime object (or None if the resource doesn't exist).
The ETag function should return a complete ETag, including quotes (e.g.
'"etag"'), since that's the only way to distinguish between weak and strong
ETags. If an unquoted ETag is returned (e.g. 'etag'), it will be converted
to a strong ETag by adding quotes.
This decorator will either pass control to the wrapped view function or
return an HTTP 304 response (unmodified) or 412 response (precondition
failed), depending upon the request method. In either case, the decorator
will add the generated ETag and Last-Modified headers to the response if
the headers aren't already set and if the request's method is safe.
c s t � ��� �fdd��}|S )Nc s� � ���fdd�}�r��g� �R i ���nd }|d ur t |�nd }|� }t�||d�}|d u r;��g� �R i ���}�jdv rW|rN|�d�sNt|�|jd<