id) 4ddlZddlmZmZmZmZmZmZddlm Z ddl m Z m Z ddl mZddlmZddlmZd Zerdd lmZed Zd ed edeeeffdZdedefdZeee geefZddde ddedededee def dZdddefdZdS)N) TYPE_CHECKING AwaitableCallableTupleTypeTypeVar)Handler)HTTPPermanentRedirect _HTTPMove)Request)StreamResponse) SystemRoute) middlewarenormalize_path_middleware) Application_FuncrequestpathreturncK||}|jj|d{V}||_|jd|fSd|fS)N)rel_urlTF)cloneapprouterresolve _match_infohttp_exception)rr alt_request match_infos L/opt/cloudlinux/venv/lib/python3.11/site-packages/aiohttp/web_middlewares.py_check_request_resolvesr"si-----K{)11+>>>>>>>>J(K ([  '>fcd|_|S)Nr )__middleware_version__)r$s r!rr!s A Hr#TF) append_slash remove_slash merge_slashesredirect_classr'r(r)r*co }|s Jdtdtdtdtffd }|S)aFactory 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 slashrhandlerrcjKt|jjtrg}d|jvr$|jdd\}}d|z}n d}|j}r)|tjdd|r2|j ds||dz r7|j dr||ddr.r,|tjdd|dzr5 r3tjdd|}||dd|D]F}tjdd|}t||d{V\}}|r |j|zG||d{VS)N?r z//+/z^//+) isinstancer routerraw_pathsplitappendresubrendswithr") rr,paths_to_checkrquerymerged_slashesresolvesr'r)r*r(s r!implz'normalize_path_middleware..implOs g(. < < CNg&&&%.44S!<< ee ' @%%bfUC&>&>??? 2GL$9$9#$>$> 2%%dSj111 1 5 5c : : 1%%d3B3i000 F F%%bfUC&D&DEEE ; ;!#sD!9!9%%nSbS&9:::& C Cvfc400*A'4*P*P$P$P$P$P$P$P!'C(.)9E)ABBBCWW%%%%%%%%%r#rr r r)r'r(r)r*correct_configurationr>s```` r!rr)sF".!>,? GG"GGGG&G&g&.&&&&&&&&Z&< Kr#rrcXtdtdtdtffd }|S)Nrr,rcK|j5||d{VcdddS#1swxYwYdS)N)r set_current_app)rr,rs r!r>z&_fix_request_current_app..implrs   / / 4 4 * * )))))))) * * * * * * * * * * * * * * * * * *s<AAr?)rr>s` r!_fix_request_current_apprDqsG*G*g*.*****Z* Kr#)r7typingrrrrrrtypedefsr web_exceptionsr r web_requestr web_responserweb_urldispatcherr__all__web_apprrstrboolr"r _MiddlewarerrDr#r!rQs KKKKKKKKKKKKKKKK<<<<<<<< ((((((******  %$$$$$$ 7 # %g BV     % E    )9^+DDE &; EEEEE E O E  EEEEP-Kr#