https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/http/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/http/__pycache__/response.cpython-310.pyc
o

��Ih;S�@sddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZmZdd
l m!Z!ddl"m#Z#ddl$m%Z%e%dej&�Z'Gdd�de�Z(Gdd�de)�Z*Gdd�d�Z+Gdd�de+�Z,Gdd�de+�Z-Gdd�de-�Z.Gdd�de,�Z/Gdd �d e/�Z0Gd!d"�d"e/�Z1Gd#d$�d$e,�Z2Gd%d&�d&e,�Z3Gd'd(�d(e,�Z4Gd)d*�d*e,�Z5Gd+d,�d,e,�Z6Gd-d.�d.e,�Z7Gd/d0�d0e,�Z8Gd1d2�d2e9�Z:Gd3d4�d4e,�Z;dS)5�N)�Mapping)�Header)�	responses)�quote�urlparse)�settings)�signals�signing)�DisallowedRedirect)�DjangoJSONEncoder)�SimpleCookie)�timezone)�CaseInsensitiveMapping�!_destruct_iterable_mapping_values)�
iri_to_uri)�	http_date)�_lazy_re_compilez ;\s*charset=(?P<charset>[^\s;]+)c@s@eZdZdd�Zddd�Zdd�Zdd	�Zddd�Zd
d�Zd
S)�ResponseHeaderscCs@t|t�sdd�t|�D�}i|_|��D]\}}|||<qdS)zm
        Populate the initial data using __setitem__ to ensure values are
        correctly encoded.
        cSsi|]\}}||�qS�r)�.0�k�vrr�6/usr/lib/python3/dist-packages/django/http/response.py�
<dictcomp>$sz,ResponseHeaders.__init__.<locals>.<dictcomp>N)�
isinstancerr�_store�items)�self�data�header�valuerrr�__init__s

�zResponseHeaders.__init__Fc
Cs�t|ttf�st|�}t|t�rd|vs%d|vs%t|t�r+d|vs%d|vr+td|��zt|t�r9|�|�W|S|�|�}W|Styj}z|rUt|dtj	d���}n
|j
d|7_
�WYd	}~|Sd	}~ww)
z�
        Convert headers key/value to ascii/latin-1 native strings.
        `charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and
        `value` can't be represented in the given charset, apply MIME-encoding.
        �
�
�
�
z-Header values can't contain newlines (got %r)zutf-8)�
maxlinelenz,, HTTP response headers must be in %s formatN)r�bytes�str�BadHeaderError�encode�decode�UnicodeErrorr�sys�maxsize�reason)rr �charset�mime_encode�errr�_convert_to_charset)s0��

��
���z#ResponseHeaders._convert_to_charsetcC�|�|�dS�N)�pop)r�keyrrr�__delitem__E�zResponseHeaders.__delitem__cCs2|�|d�}|j|ddd�}||f|j|��<dS)N�ascii�latin-1T)r1)r3r�lower�rr7r rrr�__setitem__HszResponseHeaders.__setitem__NcCs|j�|��|�Sr5)rr6r<)rr7�defaultrrrr6MszResponseHeaders.popcCs||vr
|||<dSdSr5rr=rrr�
setdefaultP��zResponseHeaders.setdefault)Fr5)	�__name__�
__module__�__qualname__r!r3r8r>r6r@rrrrrs

rc@�eZdZdS)r)N�rBrCrDrrrrr)U�r)c@seZdZdZdZd9dd�Zedd��Zejdd��Zed	d
��Z	e	jdd
��Z	dd
�Z
e
Zedd��Zdd�Z
dd�Zdd�Zdd�ZeZdd�Zd:dd�Z		d;dd �Zd!d"�Zd<d#d$�Zd=d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z dS)>�HttpResponseBasez�
    An HTTP response base class with dictionary-accessed headers.

    This class doesn't handle content. It should not be used directly.
    Use the HttpResponse and StreamingHttpResponse subclasses instead.
    ��Nc	Cs�t|pi�|_||_|rd|jvrtd��d|jvr(|dur#d|j}||jd<g|_d|_t�|_d|_	|durazt
|�|_Wn
ttfyMtd��wd|jkr\dksatd��td��||_
dS)	N�Content-TypezX'headers' must not contain 'Content-Type' when the 'content_type' parameter is provided.ztext/html; charset=%sFz$HTTP status code must be an integer.�diWz4HTTP status code must be an integer from 100 to 599.)r�headers�_charset�
ValueErrorr0�_resource_closers�_handler_classr�cookies�closed�int�status_code�	TypeError�_reason_phrase)r�content_type�statusr/r0rLrrrr!cs2�


��
zHttpResponseBase.__init__cCs|jdur|jSt�|jd�S)NzUnknown Status Code)rVr�getrT�rrrr�
reason_phrases
zHttpResponseBase.reason_phrasecC�
||_dSr5)rV�rr rrrr[��
cCs@|jdur|jS|�dd�}t�|�}|r|d�dd�StjS)NrJ�r0�")rMrY�_charset_from_content_type_re�search�replacer�DEFAULT_CHARSET)rrW�matchedrrrr0�s

zHttpResponseBase.charsetcCr\r5)rMr]rrrr0�r^cs*dd���fdd�|j��D�}d�|�S)zHTTP headers as a bytestring.cSst|t�r|S|�|�Sr5)rr'r*)�val�encodingrrr�to_bytes�sz4HttpResponseBase.serialize_headers.<locals>.to_bytescs(g|]\}}�|d�d�|d��qS)r:s: r;r)rr7r �rhrr�
<listcomp>�s��z6HttpResponseBase.serialize_headers.<locals>.<listcomp>s
)rLr�join)rrLrrir�serialize_headers�s

�
z"HttpResponseBase.serialize_headerscCsd|jvrd|jdSdS)NrJz, "%s"r_�rLrZrrr�_content_type_for_repr�sz'HttpResponseBase._content_type_for_reprcCs||j|<dSr5rm)rrr rrrr>�r9zHttpResponseBase.__setitem__cCs|j|=dSr5rm�rrrrrr8��zHttpResponseBase.__delitem__cCs
|j|Sr5rmrorrr�__getitem__��
zHttpResponseBase.__getitem__cCs
||jvS)z$Case-insensitive check for a header.rmrorrr�
has_header�r^zHttpResponseBase.has_headercCs
|j��Sr5)rLrrZrrrr�rrzHttpResponseBase.itemscCs|j�||�Sr5)rLrY)rr�	alternaterrrrY�r9zHttpResponseBase.getr_�/Fc
CsB||j|<|dur?t|tj�r7t�|�rt�|tj�}||��}
|
tjdd�}
d}t	d|
j
d|
j�}n||j|d<nd|j|d<|durbt|�|j|d<|sbt
t��|�|j|d<|durm||j|d	<|durx||j|d
<|r�d|j|d<|r�d|j|d
<|	r�|	��dvr�td��|	|j|d<dSdS)a+
        Set a cookie.

        ``expires`` can be:
        - a string in the correct format,
        - a naive ``datetime.datetime`` object in UTC,
        - an aware ``datetime.datetime`` object in any time zone.
        If it is a ``datetime.datetime`` object then calculate ``max_age``.
        N�)�secondsri�Q�expiresr_zmax-age�path�domainT�secure�httponly)�lax�none�strictz,samesite must be "lax", "none", or "strict".�samesite)rQr�datetimer
�is_aware�
make_naive�utc�utcnow�	timedelta�max�daysrwrSr�timer<rN)rr7r �max_agerxryrzr{r|r��deltarrr�
set_cookie�s8

�zHttpResponseBase.set_cookiecCs|j�||�dS)z,Set a header unless it has already been set.N)rLr@r=rrrr@��zHttpResponseBase.setdefaultcKs*tj||d��|�}|j||fi|��S)N)�salt)r	�get_cookie_signer�signr�)rr7r r��kwargsrrr�set_signed_cookie�sz"HttpResponseBase.set_signed_cookiec	Cs6|�d�p|o|��dk}|j|d|||d|d�dS)N)z	__Secure-z__Host-r~rzThu, 01 Jan 1970 00:00:00 GMT)r�ryrzr{rxr�)�
startswithr<r�)rr7ryrzr�r{rrr�
delete_cookie�s
�

�zHttpResponseBase.delete_cookiecCs@t|ttf�rt|�St|t�rt|�|j��St|��|j�S)z=Turn a value into a bytestring encoded in the output charset.)rr'�
memoryviewr(r*r0r]rrr�
make_bytess
	
zHttpResponseBase.make_bytesc	CsL|jD]}z|�WqtyYqw|j��d|_tjj|jd�dS)NT)�sender)rO�	Exception�clearrRr�request_finished�sendrP)r�closerrrr�closes

�
zHttpResponseBase.closecC�td|jj���Nz This %s instance is not writable��OSError�	__class__rB�r�contentrrr�write&�zHttpResponseBase.writecCsdSr5rrZrrr�flush)�zHttpResponseBase.flushcCr�)Nz)This %s instance cannot tell its positionr�rZrrr�tell,r�zHttpResponseBase.tellcC�dS�NFrrZrrr�readable2r�zHttpResponseBase.readablecCr�r�rrZrrr�seekable5r�zHttpResponseBase.seekablecCr�r�rrZrrr�writable8r�zHttpResponseBase.writablecCr�r�r�)r�linesrrr�
writelines;r�zHttpResponseBase.writelines)NNNNNr5)r_NNruNFFN)r_)ruNN)!rBrCrD�__doc__rTr!�propertyr[�setterr0rl�	__bytes__rnr>r8rqrs�__contains__rrYr�r@r�r�r�r�r�r�r�r�r�r�r�rrrrrHYsL








�.

rHcs�eZdZdZdZd�fdd�	Zdd�Zdd	�ZeZe	d
d��Z
e
jdd��Z
d
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS)�HttpResponsezs
    An HTTP response class with a string as content.

    This content can be read, appended to, or replaced.
    F�c�t�j|i|��||_dSr5)�superr!r�)rr��argsr��r�rrr!Hs
zHttpResponse.__init__cCsd|jj|j|jd�S)Nz5<%(cls)s status_code=%(status_code)d%(content_type)s>)�clsrTrW�r�rBrTrnrZrrr�__repr__Ms
�zHttpResponse.__repr__cCs|��d|jS)z6Full HTTP message, including headers, as a bytestring.s

)rlr�rZrrr�	serializeTr�zHttpResponse.serializecC�d�|j�S�Nr�)rk�
_containerrZrrrr�ZszHttpResponse.contentcstt|d�r/t|tttf�s/d��fdd�|D��}t|d�r.z|��Wnty-Ynwn��|�}|g�_	dS)N�__iter__r�c3s�|]}��|�VqdSr5)r�)r�chunkrZrr�	<genexpr>es�z'HttpResponse.content.<locals>.<genexpr>r�)
�hasattrrr'r�r(rkr�r�r�r�)rr r�rrZrr�^s��
��
cC�
t|j�Sr5)�iterr�rZrrrr�prrzHttpResponse.__iter__cCs|j�|�|��dSr5)r��appendr�r�rrrr�sszHttpResponse.writecCr�r5)�lenr�rZrrrr�vrrzHttpResponse.tellcC�|jSr5)r�rZrrr�getvaluey�zHttpResponse.getvaluecCr�)NTrrZrrrr�|r�zHttpResponse.writablecCs|D]}|�|�qdSr5)r�)rr��linerrrr�rAzHttpResponse.writelines)r�)rBrCrDr��	streamingr!r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr�rr�?s"

r�csdeZdZdZdZd�fdd�	Zedd��Zedd	��Zej	d
d	��Zdd�Z
d
d�Zdd�Z�Z
S)�StreamingHttpResponsea$
    A streaming HTTP response class with an iterator as content.

    This should only be iterated once, when the response is streamed to the
    client. However, it can be appended to or replaced with a new iterator
    that wraps the original content (or yields entirely new content).
    Trcr�r5)r�r!�streaming_content)rr�r�r�r�rrr!�s
zStreamingHttpResponse.__init__cCr�)NzMThis %s instance has no `content` attribute. Use `streaming_content` instead.)�AttributeErrorr�rBrZrrrr��s
��zStreamingHttpResponse.contentcCst|j|j�Sr5)�mapr��	_iteratorrZrrrr���z'StreamingHttpResponse.streaming_contentcCr4r5)�_set_streaming_contentr]rrrr��r�cCs*t|�|_t|d�r|j�|j�dSdS)Nr�)r�r�r�rOr�r�r]rrrr��s

�z,StreamingHttpResponse._set_streaming_contentcCr�r5)r�rZrrrr��r�zStreamingHttpResponse.__iter__cCr�r�)rkr�rZrrrr��rpzStreamingHttpResponse.getvalue)r)rBrCrDr�r�r!r�r�r�r�r�r�r�r�rrr�rr��s


r�cs@eZdZdZdZddd��fdd�
Z�fdd	�Zd
d�Z�ZS)�FileResponsez>
    A streaming HTTP response class optimized for files.
    iFr_)�
as_attachment�filenamecs"||_||_t�j|i|��dSr5)r�r�r�r!)rr�r�r�r�r�rrr!�szFileResponse.__init__cslt|d�sd�_t��|�S|�_�t�d�r�j��j�t��fdd�d�}����t��|�dS)N�readr�cs���j�Sr5)r��
block_sizer��filelikerrr�<lambda>�sz5FileResponse._set_streaming_content.<locals>.<lambda>r�)	r��file_to_streamr�r�rOr�r�r��set_headersr]r�r�rr��s



z#FileResponse._set_streaming_contentcCsTdddd�}t|dd�}t|t�r|r|n|j}tj�|�r)tj�|j�|j	d<n
t
|d�r6|��j|j	d<|j	�
d	d
��d�r\|rWt�|�\}}|�
||�}|pRd|j	d	<nd|j	d	<|jpdtj�|�}|r�|jrld
nd}z|�d�d�|�dd��dd��}Wnty�d�t|��}Ynwd�||�|j	d<dS|jr�d
|j	d<dSdS)z�
        Set some common response headers (Content-Length, Content-Type, and
        Content-Disposition) based on the `filelike` response content.
        zapplication/x-bzipzapplication/gzipzapplication/x-xz)�bzip2�gzip�xz�nameNzContent-Length�	getbufferrJr_z	text/htmlzapplication/octet-stream�
attachment�inliner:z
filename="{}"�\z\\r`z\"zfilename*=utf-8''{}z{}; {}zContent-Disposition)�getattrrr(r��osry�isabs�getsizer�rLr�r��nbytesrYr��	mimetypes�
guess_type�basenamer�r*�formatrc�UnicodeEncodeErrorr)rr��encoding_mapr�rWrg�disposition�	file_exprrrrr��s>�


���zFileResponse.set_headers)	rBrCrDr�r�r!r�r�r�rrr�rr��sr�cs8eZdZgd�Z�fdd�Zedd��Zdd�Z�ZS)�HttpResponseRedirectBase)�http�https�ftpcsRt�j|i|��t|�|d<tt|��}|jr%|j|jvr'td|j��dSdS)N�Locationz)Unsafe redirect to URL with protocol '%s')r�r!rrr(�scheme�allowed_schemesr
)r�redirect_tor�r��parsedr�rrr!�s�z!HttpResponseRedirectBase.__init__cCs|dS)Nr�rrZrrrr��sz!HttpResponseRedirectBase.<lambda>cCsd|jj|j|j|jd�S)NzD<%(cls)s status_code=%(status_code)d%(content_type)s, url="%(url)s">)r�rTrW�url)r�rBrTrnrrZrrrr��s�z!HttpResponseRedirectBase.__repr__)	rBrCrDr�r!r�rr�r�rrr�rr��s
r�c@�eZdZdZdS)�HttpResponseRedirecti.N�rBrCrDrTrrrrr�rc@r)�HttpResponsePermanentRedirecti-Nrrrrrrrrcs0eZdZdZ�fdd�Zejjdd��Z�ZS)�HttpResponseNotModifiedi0cst�j|i|��|d=dS)Nzcontent-type)r�r!)rr�r�r�rrr!s
z HttpResponseNotModified.__init__cCs|rtd��g|_dS)Nz7You cannot set content to a 304 (Not Modified) response)r�r�r]rrrr�s
zHttpResponseNotModified.content)	rBrCrDrTr!r�r�r�r�rrr�rrs
rc@r)�HttpResponseBadRequesti�Nrrrrrrrrc@r)�HttpResponseNotFoundi�Nrrrrrr!rrc@r)�HttpResponseForbiddeni�Nrrrrrr	%rr	cs(eZdZdZ�fdd�Zdd�Z�ZS)�HttpResponseNotAllowedi�cs$t�j|i|��d�|�|d<dS)Nz, �Allow)r�r!rk)r�permitted_methodsr�r�r�rrr!,szHttpResponseNotAllowed.__init__cCsd|jj|j|j|dd�S)NzC<%(cls)s [%(methods)s] status_code=%(status_code)d%(content_type)s>r)r�rTrW�methodsr�rZrrrr�0s�zHttpResponseNotAllowed.__repr__)rBrCrDrTr!r�r�rrr�rr
)sr
c@r)�HttpResponseGonei�Nrrrrrr9rrc@r)�HttpResponseServerErrori�Nrrrrrr=rrc@rE)�Http404NrFrrrrrArGrcs(eZdZdZeddf�fdd�	Z�ZS)�JsonResponseaH
    An HTTP response class that consumes data to be serialized to JSON.

    :param data: Data to be dumped into json. By default only ``dict`` objects
      are allowed to be passed due to a security flaw before EcmaScript 5. See
      the ``safe`` parameter for more information.
    :param encoder: Should be a json encoder class. Defaults to
      ``django.core.serializers.json.DjangoJSONEncoder``.
    :param safe: Controls if only ``dict`` objects may be serialized. Defaults
      to ``True``.
    :param json_dumps_params: A dictionary of kwargs passed to json.dumps().
    TNcs^|rt|t�std��|duri}|�dd�tj|fd|i|��}t�jdd|i|��dS)NzTIn order to allow non-dict objects to be serialized set the safe parameter to False.rWzapplication/jsonr�r�r)r�dictrUr@�json�dumpsr�r!)rr�encoder�safe�json_dumps_paramsr�r�rrr!Ss�zJsonResponse.__init__)rBrCrDr�rr!r�rrr�rrEs

�r)<r�rr�r��rer-r��collections.abcr�email.headerr�http.clientr�urllib.parserr�django.confr�django.corerr	�django.core.exceptionsr
�django.core.serializers.jsonr�django.http.cookier�django.utilsr
�django.utils.datastructuresrr�django.utils.encodingr�django.utils.httpr�django.utils.regex_helperr�IrarrNr)rHr�r�r�r�rrrrrr	r
rrr�rrrrrr�<module>sR8gE-A

https://t.me/RX1948 - 2025