HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/aiohttp/__pycache__/web_middlewares.cpython-310.pyc
o

���gE�@s�ddlZddlmZmZmZmZddlmZmZddl	m
Z
mZddlm
Z
ddlmZddlmZd	Zer<dd
lmZed�Zde
d
edeee
ffdd�Zdedefdd�Zddded�dedededee
def
dd�Zdddefdd �ZdS)!�N)�
TYPE_CHECKING�Tuple�Type�TypeVar�)�Handler�
Middleware)�HTTPMove�HTTPPermanentRedirect)�Request)�StreamResponse)�SystemRoute)�
middleware�normalize_path_middleware)�Application�_Func�request�path�returnc�sB�|j|d�}|jj�|�IdH}||_|jdurd|fSd|fS)N)�rel_urlTF)�clone�app�router�resolve�_match_info�http_exception)rr�alt_request�
match_info�r�B/usr/local/lib/python3.10/dist-packages/aiohttp/web_middlewares.py�_check_request_resolvess�
r �fcCs
d|_|S)Nr)�__middleware_version__)r!rrrr!srTF)�append_slash�remove_slash�
merge_slashes�redirect_classr#r$r%r&cs>�o�}|sJd��tdtdtdtf����fdd��}|S)a�Factory for producing a middleware that normalizes the path of a request.

    Normalizing means:
        - Add or remove a trailing slash to the path.
        - Double slashes are replaced by one.

    The middleware returns as soon as it finds a path that resolves
    correctly. The order if both merge and append/remove are enabled is
        1) merge slashes
        2) append/remove slash
        3) both merge slashes and append/remove slash.
    If the path resolves with at least one of those conditions, it will
    redirect to the new path.

    Only one of `append_slash` and `remove_slash` can be enabled. If both
    are `True` the factory will raise an assertion error

    If `append_slash` is `True` the middleware will append a slash when
    needed. If a resource is defined with trailing slash and the request
    comes without it, it will append it automatically.

    If `remove_slash` is `True`, `append_slash` must be `False`. When enabled
    the middleware will remove trailing slashes and redirect if the resource
    is defined

    If merge_slashes is True, merge multiple consecutive slashes in the
    path into one.
    z#Cannot both remove and append slashr�handlerrc�s0�t|jjt�r�g}d|jvr|j�dd�\}}d|}nd}|j}�r.|�t�dd|���r=|j	�
d�s=|�|d��rN|j	�
d�rN|�|dd���r^�r^|�t�dd|d���rr�rrt�dd|�}|�|dd��|D]}t�dd|�}t||�IdH\}}|r��|j|��qt||�IdHS)N�?r�z//+�/���z^//+)�
isinstancer�router
�raw_path�split�append�re�subr�endswithr )rr'�paths_to_checkr�query�merged_slashes�resolves�r#r%r&r$rr�implLs4�

�z'normalize_path_middleware.<locals>.impl�rrrr)r#r$r%r&�correct_configurationr9rr8rr&s

#"rrrcs"tdtdtdtf�fdd��}|S)Nrr'rc�s4�|j}|j}�|_z||�IdHW||_S||_w)N)r�current_app)rr'r�prev�rrrr9os�z&_fix_request_current_app.<locals>.implr:)rr9rr>r�_fix_request_current_appns	r?)r1�typingrrrr�typedefsrr�web_exceptionsr	r
�web_requestr�web_responser�web_urldispatcherr
�__all__�web_apprr�str�boolr rrr?rrrr�<module>s:�����
�H