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/starlette/__pycache__/staticfiles.cpython-310.pyc
o

�h!�@s�ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
Z
ddlZ
ddlm
Z
ddlmZmZddlmZddlmZmZmZddlmZmZmZejed	fZGd
d�de�ZGdd
�d
�ZdS)�)�annotationsN)�	parsedate)�get_route_path)�URL�Headers)�
HTTPException)�FileResponse�RedirectResponse�Response)�Receive�Scope�Sendzos.PathLike[str]cs"eZdZdZd�fdd�Z�ZS)�NotModifiedResponse)z
cache-controlzcontent-location�date�etag�expires�vary�headersrcs&t�jd�fdd�|��D�d�dS)Ni0cs i|]\}}|�jvr||�qS�)�NOT_MODIFIED_HEADERS)�.0�name�value��selfr�H/usr/local/CyberCP/lib/python3.10/site-packages/starlette/staticfiles.py�
<dictcomp>#s z0NotModifiedResponse.__init__.<locals>.<dictcomp>)�status_coder)�super�__init__�items)rr��	__class__rrr s
�zNotModifiedResponse.__init__)rr)�__name__�
__module__�__qualname__rr�
__classcell__rrr!rrs	rc@s~eZdZdddddd�d6dd�Z		d7d8dd�Zd9dd�Zd:dd�Zd;d!d"�Zd<d$d%�Z	&d=d>d-d.�Z	d?d/d0�Z
d@d4d5�ZdS)A�StaticFilesNFT)�	directory�packages�html�	check_dir�follow_symlinkr(�PathLike | Noner)�"list[str | tuple[str, str]] | Noner*�boolr+r,�return�NonecCs`||_||_|�||�|_||_d|_||_|r*|dur,tj�	|�s.t
d|�d���dSdSdS)NF�Directory 'z' does not exist)r(r)�get_directories�all_directoriesr*�config_checkedr,�os�path�isdir�RuntimeError)rr(r)r*r+r,rrrr(s	�zStaticFiles.__init__�list[PathLike]cCs�g}|dur|�|�|pgD]P}t|t�r|\}}nd}tj�|�}|dus/Jd|�d���|jdus<Jd|�d���tj�	tj�
|jd|��}tj�|�sZJd|�d|�d���|�|�q|S)z�
        Given `directory` and `packages` arguments, return a list of all the
        directories that should be used for serving static files from.
        N�staticszPackage z could not be found.z..r2z
' in package )�append�
isinstance�tuple�	importlib�util�	find_spec�originr6r7�normpath�joinr8)rr(r)�directories�package�statics_dir�spec�package_directoryrrrr3:s 	


�zStaticFiles.get_directories�scoper�receiver�sendr
c�s^�|ddks	J�|js|��IdHd|_|�|�}|�||�IdH}||||�IdHdS)z'
        The ASGI entry point.
        �type�httpNT)r5�check_config�get_path�get_response)rrJrKrLr7�responserrr�__call__Ws�
zStaticFiles.__call__�strcCs"t|�}tj�tjj|�d���S)z�
        Given the ASGI scope, return the `path` string to serve up,
        with OS specific path separators, and any '..', '.' components removed.
        �/)rr6r7rCrD�split)rrJ�
route_pathrrrrPeszStaticFiles.get_pathr7r
c
�sz�|ddvrtdd��ztj�|j|�IdH\}}Wn$ty'tdd��ty?}z
|jtjkr9tdd��|�d}~ww|rOt	�
|j�rO|�|||�S|r�t	�
|j�r�|jr�tj�|d�}tj�|j|�IdH\}}|dur�t	�
|j�r�|d	�d
�s�t|d�}|j|jd
d�}t|d
�S|�|||�S|jr�tj�|jd�IdH\}}|r�t	�
|j�r�t||dd�Stdd��)z`
        Returns an HTTP response, given the incoming path, method and request headers.
        �method)�GET�HEADi�)rNi�i�z
index.htmlr7rU�rJ)r7)�urlz404.html)�stat_resultr)r�anyio�	to_thread�run_sync�lookup_path�PermissionError�OSError�errno�ENAMETOOLONG�stat�S_ISREG�st_mode�
file_response�S_ISDIRr*r6r7rD�endswithr�replacer	r)rr7rJ�	full_pathr]�exc�
index_pathr\rrrrQms:�


��


zStaticFiles.get_response�!tuple[str, os.stat_result | None]c
Cs�|jD]G}tj�||�}|jrtj�|�}tj�|�}ntj�|�}tj�|�}tj�||g�t|�kr5qz
|t�	|�fWSt
tfyJYqwdS)N)�N)r4r6r7rDr,�abspath�realpath�
commonpathrTrf�FileNotFoundError�NotADirectoryError)rr7r(�joined_pathrmrrrra�s
�zStaticFiles.lookup_path��rm�PathLiker]�os.stat_resultr�intcCs4t|d�}t|||d�}|�|j|�rt|j�S|S)Nr[)rr])rr�is_not_modifiedrr)rrmr]rJr�request_headersrRrrrri�s


zStaticFiles.file_responsec�s��|jdurdSztj�tj|j�IdH}Wnty&td|j�d���wt�|j	�s<t�
|j	�s>td|j�d���dSdS)z�
        Perform a one-off configuration check that StaticFiles is actually
        pointed at a directory, so that we can raise loud errors rather than
        just returning 404 responses.
        NzStaticFiles directory 'z' does not exist.zStaticFiles path 'z' is not a directory.)r(r^r_r`r6rfrur9rjrh�S_ISLNK)rr]rrrrO�s�
��zStaticFiles.check_config�response_headersrr}cCs�z|d}|d}|dd�|�d�D�vrWdSWn	ty"Ynwz$t|d�}t|d�}|d	ur?|d	urB||krEWdSWd
SWd
SWd
StyQYd
Sw)z�
        Given the request and response headers, return `True` if an HTTP
        "Not Modified" response could be returned instead.
        z
if-none-matchrcSsg|]}|�d��qS)z W/)�strip)r�tagrrr�
<listcomp>�sz/StaticFiles.is_not_modified.<locals>.<listcomp>�,Tzif-modified-sincez
last-modifiedNF)rV�KeyErrorr)rrr}�
if_none_matchr�if_modified_since�
last_modifiedrrrr|�s0�������zStaticFiles.is_not_modified)r(r-r)r.r*r/r+r/r,r/r0r1)NN)r(r-r)r.r0r:)rJrrKrrLr
r0r1)rJrr0rT)r7rTrJrr0r
)r7rTr0rp)rx)
rmryr]rzrJrrr{r0r
)r0r1)rrr}rr0r/)r#r$r%rr3rSrPrQrarirOr|rrrrr''s$��



*�
r') �
__future__rrd�importlib.utilr?r6rf�typing�email.utilsrr^�anyio.to_thread�starlette._utilsr�starlette.datastructuresrr�starlette.exceptionsr�starlette.responsesrr	r
�starlette.typesrrr
�UnionrTryrr'rrrr�<module>s"