wce ddlZddlmZmZmZmZddlmZmZddl m Z m Z ddl m Z ddlmZddlmZd Zerdd lmZed Zd e d edeee ffdZdedefdZddde ddedededee def dZdddefdZy)N) TYPE_CHECKINGTupleTypeTypeVar)Handler Middleware)HTTPMoveHTTPPermanentRedirect)Request)StreamResponse) SystemRoute) middlewarenormalize_path_middleware) Application_FuncrequestpathreturncK|j|}|jjj|d{}||_|j d|fSd|fS7w)N)rel_urlTF)cloneapprouterresolve _match_infohttp_exception)rr alt_request match_infos 9/usr/lib/python3/dist-packages/aiohttp/web_middlewares.py_check_request_resolvesr!sa----K{{))11+>>J(K  ([  '> ?s;AA Afcd|_|S)Nr)__middleware_version__)r"s r rr!s A HTF) append_slash remove_slash merge_slashesredirect_classr&r'r(r)cvxr }|sJdtdtdtdtffd }|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 slashrhandlerrchKt|jjtrug}d|jvr%|jj dd\}}d|z}nd}|j}r&|j tjdd|r/|jjds|j |dz r/|jjdr|j |ddr+r)|j tjdd|dzr- r+tjdd|}|j |dd|D]G}tjdd|}t||d{\}}|s4 |j|z||d{S707w)N?rz//+/z^//+) isinstancerrouterraw_pathsplitappendresubrendswithr!) rr+paths_to_checkrquerymerged_slashesresolvesr&r(r)r's r implz'normalize_path_middleware..implLs g((.. <Ng&&&%..44S!< ee ''%%bffUC&>?GLL$9$9#$>%%dSj1 5 5c :%%d3Bi0%%bffUC&DE!#sD!9%%nSb&9:& Cvvfc40*A'4*P$P!'()9)9E)ABB  C W%%% %Q&s*E:F2=F.> F2!F2)F0*F20F2rr rr )r&r'r(r)correct_configurationr=s```` r rr&sQF".!>,? G"GG &G&g&.&&< Kr%rrcJtdtdtdtffd }|S)Nrr+rcK|jj5||d{cdddS7 #1swYyxYww)N)rset_current_app)rr+rs r r=z&_fix_request_current_app..implosC    / / 4 * )) * *) * *s%A ;9; A;AAr>)rr=s` r _fix_request_current_apprCns1*G*g*.** Kr%)r6typingrrrrtypedefsrr web_exceptionsr r web_requestr web_responser web_urldispatcherr__all__web_apprrstrboolr!rrrCr%r rOs 66); (*  $ 7 # %g BV  % E %: EEE E N E  EP-Jr%