HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/django/http/__pycache__/request.cpython-310.pyc
o

�h�c�@snddlZddlZddlmZddlmZddlmZmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZmZmZddlmZdd	lmZmZmZdd
lmZmZmZddlm Z m!Z!ddl"m#Z#dd
l$m%Z%m&Z&ddl'm(Z(e)�Z*e(d�Z+Gdd�de,�Z-Gdd�de.�Z/Gdd�d�Z0Gdd�de�Z1Gdd�de�Z2Gdd�d�Z3dd�Z4dd�Z5d d!�Z6d"d#�Z7dS)$�N)�BytesIO)�chain)�	parse_qsl�quote�	urlencode�urljoin�urlsplit)�settings)�signing)�DisallowedHost�ImproperlyConfigured�RequestDataTooBig�TooManyFieldsSent)�
uploadhandler)�MultiPartParser�MultiPartParserError�TooManyFilesSent)�CaseInsensitiveMapping�
ImmutableList�MultiValueDict)�escape_uri_path�
iri_to_uri)�cached_property)�is_same_domain�parse_header_parameters)�_lazy_re_compilez4^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9\.:]+\])(:[0-9]+)?$c@seZdZdS)�UnreadablePostErrorN)�__name__�
__module__�__qualname__�r r �F/usr/local/CyberCP/lib/python3.10/site-packages/django/http/request.pyr%src@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)rrr�__doc__r r r r!r")sr"c@sNeZdZdZdZgZdd�Zdd�Zedd��Z	ed	d
��Z
dd�Zd
d�Zdd�Z
dd�Zdd�ZdCdd�ZdCdd�Zdd�Zeddfdd�ZdDdd �Zed!d"��Zd#d$�Zed%d&��Zd'd(�Zed)d*��Zejd+d*��Zd,d-�Zed.d/��Zejd0d/��Zd1d2�Zed3d4��Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dS)E�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__:s
zHttpRequest.__init__cCs6|jdus	|��sd|jjSd|jj|j|��fS)Nz<%s>z<%s: %s %r>)r/�
get_full_path�	__class__rr3r r r!�__repr__Ls�zHttpRequest.__repr__cCs
t|j�S�N)�HttpHeadersr+r3r r r!�headersU�
zHttpRequest.headerscCst|j�dd��S)z%Return a list of MediaType instances.�Acceptz*/*)�parse_accept_headerr;�getr3r r r!�accepted_typesYszHttpRequest.accepted_typescst�fdd�|jD��S)Nc3s�|]}|���VqdSr9)�match)�.0�
accepted_type��
media_typer r!�	<genexpr>_s�

�z&HttpRequest.accepts.<locals>.<genexpr>)�anyr@)r4rEr rDr!�accepts^s�zHttpRequest.acceptscCs`t|�dd��\|_|_d|jvr.z
t�|jd�Wn
ty%YdSw|jd|_dSdS)z/Set content_type, content_params, and encoding.�CONTENT_TYPEr&�charsetN)rr?r1r2�codecs�lookup�LookupError�encoding)r4�metar r r!�_set_content_type_paramscs
�
��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_HOSTr+�get_port�	is_secure)r4�host�server_portr r r!�
_get_raw_hostps
	
�

�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.)r[r	�
ALLOWED_HOSTS�DEBUG�split_domain_port�
validate_hostr)r4rY�
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_PORTr+�str)r4rbr r r!rW�s


�zHttpRequest.get_portFcC�|�|j|�Sr9)�_get_full_pathr-�r4�force_append_slashr r r!r6��zHttpRequest.get_full_pathcCrir9)rjr.rkr r r!�get_full_path_info�rmzHttpRequest.get_full_path_infoc	CsLdt|�|r
|�d�s
dnd|j�dd�r"dt|j�dd��fSdfS)N�%s%s%s�/r&�QUERY_STRING�?)r�endswithr+r?r)r4r-rlr r r!rj�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)r*�KeyError�RAISE_ERRORr
�get_cookie_signer�unsign�BadSignature)r4�key�defaultrtru�cookie_value�valuer r r!�get_signed_cookie�s"����zHttpRequest.get_signed_cookiecCs�|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//%srpz/./z/../z//�)
r6rhr�scheme�netlocr-�
startswith�_current_scheme_hostrr)r4�location�bitsr r r!�build_absolute_uri�s&	
���



�zHttpRequest.build_absolute_uricCsd�|j|���S)Nz{}://{})�formatr�rdr3r r r!r��sz HttpRequest._current_scheme_hostcCsdS)zf
        Hook for subclasses like WSGIRequest to implement. Return 'http' by
        default.
        �httpr r3r r r!�_get_scheme�szHttpRequest._get_schemecCsltjr2ztj\}}Wntytd��w|j�|�}|dur2|�dd�^}}|��|kr0dSdS|��S)NzJThe SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.�,��httpsr�)	r	�SECURE_PROXY_SSL_HEADER�
ValueErrorrr+r?�split�stripr�)r4�header�secure_value�header_value�_r r r!r��s��zHttpRequest.schemecCs
|jdkS)Nr�)r�r3r r r!rX
s
zHttpRequest.is_securecCs|jSr9��	_encodingr3r r r!rNszHttpRequest.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�)r4�valr r r!rNs

�cs�fdd�tjD��_dS)Ncsg|]}t�|���qSr )r�load_handler)rB�handlerr3r r!�
<listcomp>"s
��z4HttpRequest._initialize_handlers.<locals>.<listcomp>)r	�FILE_UPLOAD_HANDLERS�_upload_handlersr3r r3r!�_initialize_handlers!s
�z HttpRequest._initialize_handlerscCs|js|��|jSr9)r�r�r3r r r!�upload_handlers'szHttpRequest.upload_handlerscCst|d�r	td��||_dS)N�_fileszGYou cannot set the upload handlers after the upload has been processed.)r��AttributeErrorr�)r4r�r r r!r�.s

�
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�rrN�parse)r4r+�	post_data�parserr r r!�parse_file_upload7s�zHttpRequest.parse_file_uploadc
Cs�t|d�sP|jrtd��tjdur"t|j�d�pd�tjkr"td��z!z|�	�|_
Wnty<}zt|j
�|�d}~wwW|j��n|j��wt|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�intr+r?r
�readr��OSErrorr�args�_stream�closer)r4�er r r!�bodyCs,
�
�����zHttpRequest.bodycCst�|_t�|_dSr9)r'r�rr�r3r r r!�_mark_post_parse_error^s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))rNNr�zmultipart/form-dataz!application/x-www-form-urlencoded)r/r'r�rr�r�r�r�r�r1rr�r�r+rrr�)r4�datar r r!�_load_post_and_filesbs2


�

�
�
�z HttpRequest._load_post_and_filescCs:t|d�rt�dd�|j��D��D]}|��qdSdS)Nr�css�|]}|dVqdS)r�Nr )rB�list_r r r!rF�s�z$HttpRequest.close.<locals>.<genexpr>)r�r�
from_iterabler��listsr�)r4�fr r r!r��s


�zHttpRequest.closec
O�@d|_z
|jj|i|��WSty}zt|j�|�d}~ww�NT)r�r�r�r�rr��r4r��kwargsr�r r r!r�����zHttpRequest.readc
Or�r�)r�r��readliner�rr�r�r r r!r��r�zHttpRequest.readlinecCst|jd�S)N�)�iterr�r3r r r!�__iter__��zHttpRequest.__iter__cCst|�Sr9)�listr3r r r!�	readlines�szHttpRequest.readlines)Fr9)(rrrr#r�r�r5r8rr;r@rHrPr[rdrWr6rnrjrwrr�r�r��propertyr�rXrN�setterr�r�r�r�r�r�r�r�r�r�r�r r r r!r$3sZ	





)






&
r$cspeZdZdZddhZ�fdd�Z�fdd�Zedd	��Zed
d��Z	edd
��Z
edd��Zedd��Z�Z
S)r:�HTTP_rIr�cs<i}|��D]\}}|�|�}|r|||<qt��|�dSr9)�items�parse_header_name�superr5)r4�environr;r�r~�name�r7r r!r5�s
�zHttpHeaders.__init__cst��|�dd��S)z:Allow header lookup using underscores in place of hyphens.r��-)r��__getitem__�replace�r4r{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_namecCs,|�dd���}||jvr|S|j�|��S�Nr�r�)r��upperr�r�r�r r r!�to_wsgi_name�s
zHttpHeaders.to_wsgi_namecCs|�dd���Sr�)r�r�r�r r r!�to_asgi_name�szHttpHeaders.to_asgi_namec��fdd�|��D�S)Nc�i|]
\}}��|�|�qSr )r��rB�header_namer~�r�r r!�
<dictcomp>��
��z-HttpHeaders.to_wsgi_names.<locals>.<dictcomp>�r��r�r;r r�r!�
to_wsgi_names��
�zHttpHeaders.to_wsgi_namescr�)Ncr�r )r�r�r�r r!r��r�z-HttpHeaders.to_asgi_names.<locals>.<dictcomp>r�r�r r�r!�
to_asgi_names�r�zHttpHeaders.to_asgi_names)rrrr�r�r5r��classmethodr�r�r�r�r��
__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_valuesrN�max_num_fieldsz
iso-8859-1zRThe number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS.)r�r5r	�DEFAULT_CHARSETrN�DATA_UPLOAD_MAX_NUMBER_FIELDS�
isinstance�bytes�decode�UnicodeDecodeErrorr�
appendlistr�r�_mutable)r4�query_stringr%rN�parse_qsl_kwargsr{r~r�r�r r!r5�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%rNF)r�r�)r��iterabler~r%rN�qr{r r r!�fromkeysszQueryDict.fromkeyscCs|jdur	tj|_|jSr9)r�r	r�r3r r r!rNs
zQueryDict.encodingcCs
||_dSr9r�)r4r~r r r!rN"r<cCs|jstd��dS)Nz$This QueryDict instance is immutable)r�r�r3r r r!�_assert_mutable&s�zQueryDict._assert_mutablec�2|��t||j�}t||j�}t��||�dSr9)r��
bytes_to_textrNr��__setitem__�r4r{r~r�r r!r*�zQueryDict.__setitem__cs|��t��|�dSr9)r�r��__delitem__r�r�r r!r0szQueryDict.__delitem__cCs4|jdd|jd�}|��D]
\}}|�||�q
|S�Nr&Tr�)r7rNr��setlist)r4�resultr{r~r r r!�__copy__4szQueryDict.__copy__cCsP|jdd|jd�}||t|�<|��D]\}}|�t�||�t�||��q|Sr)r7rN�idr�r�copy�deepcopy)r4�memorr{r~r r r!�__deepcopy__:s
zQueryDict.__deepcopy__cs8���t|�j�}�fdd�|D�}t��||�dS)Ncsg|]}t|�j��qSr )rrN)rB�eltr3r r!r�Dsz%QueryDict.setlist.<locals>.<listcomp>)r�rrNr�r)r4r{r�r�r3r!rAszQueryDict.setlistcs|��t��||�Sr9)r�r��setlistdefault)r4r{�default_listr�r r!rG�zQueryDict.setlistdefaultcr�r9)r�rrNr�r�rr�r r!r�KrzQueryDict.appendlistcs|��t�j|g|�R�Sr9)r�r��pop)r4r{r�r�r r!rQsz
QueryDict.popcs|��t���Sr9)r�r��popitemr3r�r r!rUs
zQueryDict.popitemcs|��t���dSr9)r�r��clearr3r�r r!rYrzQueryDict.clearcs.|��t||j�}t||j�}t��||�Sr9)r�rrNr��
setdefault)r4r{r|r�r r!r]szQueryDict.setdefaultcCs
|�i�S)z%Return a mutable copy of this object.)r
r3r r r!r
cr<zQueryDict.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!�encodexsz#QueryDict.urlencode.<locals>.encodecSst||i�Sr9)rrr r r!r}r�c3s.�|]}����j�t|���j��VqdSr9)rrNrh)rBr)rrr4r r!rF�s
��
�z&QueryDict.urlencode.<locals>.<genexpr>�&)rrNr��extend�join)r4r�outputr�r )rrrr4r!rgs

�
zQueryDict.urlencode)NFN)r&FNr9)rrrr#r�r�r5r�r�r�rNr�r�rrrr
rrr�rrrrr
rr�r r r�r!r'�s2

r'c@s8eZdZdd�Zdd�Zdd�Zedd��Zd	d
�ZdS)�	MediaTypecCs.t|r|nd�\}|_|�d�\|_}|_dS)Nr&rp)r�params�	partition�	main_type�sub_type)r4�media_type_raw_line�	full_typer�r r r!r5�s

�zMediaType.__init__cCs@d�dd�|j��D��}d|j|jrd|j|fSd|fS)Nr&css �|]\}}d||fVqdS)z; %s=%sNr )rBrrr r r!rF�s�z$MediaType.__str__.<locals>.<genexpr>roz/%s)rr r�r"r#)r4�
params_strr r r!�__str__�s��zMediaType.__str__cCsd|jj|fS)Nz<%s: %s>)r7rr3r r r!r8�szMediaType.__repr__cCs|jdko	|jdkS)N�*)r"r#r3r r r!�is_all_types�r�zMediaType.is_all_typescCs6|jrdSt|�}|j|jkr|jd|jhvrdSdS)NTr(F)r)rr"r#)r4�otherr r r!rA�szMediaType.matchN)	rrrr5r'r8r�r)rAr 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�rh)�srNr r r!r�s
rcCsx|��}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&�:r�r�r�.N)�lower�host_validation_rerA�rsplitr�rs)rYr�rarbr r r!r^�s
 r^cst�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(N)r)rB�pattern�rYr r!rF�s�
�z validate_host.<locals>.<genexpr>)rG)rYr`r r4r!r_�s�r_cCsdd�|�d�D�S)NcSsg|]
}|��rt|��qSr )r�r)rB�tokenr r r!r��sz'parse_accept_header.<locals>.<listcomp>r�)r�)r�r r r!r>�sr>)8rKr
�ior�	itertoolsr�urllib.parserrrrr�django.confr	�django.corer
�django.core.exceptionsrrr
r�django.core.filesr�django.http.multipartparserrrr�django.utils.datastructuresrrr�django.utils.encodingrr�django.utils.functionalr�django.utils.httprr�django.utils.regex_helperr�objectrwr1r�r�	Exceptionr"r$r:r'rrr^r_r>r r r r!�<module>s@�
y3,"