
    hE                        d dl Z d dlmZmZmZmZ ddlmZmZ ddl	m
Z
mZ ddlmZ ddlmZ ddlmZ d	Zerdd
lmZ  ed          Zdededeeef         fdZdedefdZdddeddedededee
         def
dZdddefdZdS )    N)TYPE_CHECKINGTupleTypeTypeVar   )Handler
Middleware)HTTPMoveHTTPPermanentRedirect)Request)StreamResponse)SystemRoute)
middlewarenormalize_path_middleware)Application_Funcrequestpathreturnc                    K   |                      |          }| j        j                            |           d {V }||_        |j        d|fS d| fS )N)rel_urlTF)cloneapprouterresolve_match_infohttp_exception)r   r   alt_request
match_infos       Y/var/www/html/prod/cognitive/venv/lib/python3.11/site-packages/aiohttp/web_middlewares.py_check_request_resolvesr!      si      -----K{)11+>>>>>>>>J(K ([  '>    fc                     d| _         | S )Nr   )__middleware_version__)r#   s    r    r   r   !   s     AHr"   TF)append_slashremove_slashmerge_slashesredirect_classr&   r'   r(   r)   c                       o }|s
J d            t           dt          dt          dt          f fd            }|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   handlerr   c                 j  K   t          | j        j        t                    rg }d| j        v r$| j                            dd          \  }}d|z   }n	d}| j        }r)|                    t          j        dd|                     r2| j	        
                    d          s|                    |dz              
r7| j	        
                    d          r|                    |d d                    r.r,|                    t          j        dd|dz                        r5
r3t          j        dd|          }|                    |d d                    |D ]F}t          j        dd|          }t          | |           d {V \  }} |r 	| j        |z             G ||            d {V S )N?r    z//+/z^//+)
isinstancer   router   raw_pathsplitappendresubr   endswithr!   )r   r+   paths_to_checkr   querymerged_slashesresolvesr&   r(   r)   r'   s          r    implz'normalize_path_middleware.<locals>.implL   s     g(.<< 	CNg&&&%.44S!<<ee' @%%bfUC&>&>??? 2GL$9$9#$>$> 2%%dSj111 1 5 5c : : 1%%d3B3i000 F F%%bfUC&D&DEEE ; ;!#sD!9!9%%nSbS&9:::& C Cvfc400*A'4*P*P$P$P$P$P$P$P!' C(.)9E)ABBBC WW%%%%%%%%%r"   r   r   r   r   )r&   r'   r(   r)   correct_configurationr=   s   ````  r    r   r   &   s    F ".!>,? GG"GGG &G &g &. & & & & & & & & Z&< Kr"   r   r   c                 X     t           dt          dt          dt          f fd            }|S )Nr   r+   r   c                 ~   K   | j         }|j        }|_        	  ||            d {V 	 ||_        S # ||_        w xY w)N)r   current_app)r   r+   r   prevr   s       r    r=   z&_fix_request_current_app.<locals>.implo   se      '
%!$
	* )))))))))%)J""TJ"))))s   3 	<r>   )r   r=   s   ` r    _fix_request_current_apprD   n   sG    *G *g *. * * * * * Z* Kr"   )r6   typingr   r   r   r   typedefsr   r	   web_exceptionsr
   r   web_requestr   web_responser   web_urldispatcherr   __all__web_appr   r   strboolr!   r   r   rD    r"   r    <module>rP      s   				 6 6 6 6 6 6 6 6 6 6 6 6 ) ) ) ) ) ) ) ) ; ; ; ; ; ; ; ;             ( ( ( ( ( ( * * * * * *
  %$$$$$$	7 	# 	%gBV 	 	 	 	% E     %:E E EE E 	E
 NE E E E EP- J      r"   