Viewing File: /opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/web_middlewares.cpython-35.pyc



Zc
@sxddlZddlmZddlmZdZddZddZd	d
dd
ded
dZddZ	dS)N)HTTPMovedPermanently)SystemRoute
middlewarenormalize_path_middlewarecs[|jd|}|jjj|IdH}||_t|jtsQd|fSd|fS)NZrel_urlTF)ZcloneappZrouterZresolveZ_match_info
isinstancerouter)requestpathZalt_request
match_infor/web_middlewares.py_check_request_resolves
s	
rcCs
d|_|S)N)Z__middleware_version__)frrr
rs	append_slashT
merge_slashesredirect_classcs"tfdd}|S)a
    Middleware that normalizes the path of a request. By normalizing
    it means:

        - Add 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 all enable is 1) merge_slashes, 2) append_slash
    and 3) both merge_slashes and append_slash. If the path resolves with
    at least one of those conditions, it will redirect to the new path.

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

    If merge_slashes is True, merge multiple consecutive slashes in the
    path into one.
    cs,t|jjtrg}d|jkrR|jjdd\}}d|}nd}|j}r|jtjdd|r|j	j
dr|j|drr|jtjdd|dxA|D]9}t||IdH\}}|r|j	|qW||IdHS)N?rz//+/)rrrrZraw_pathsplitappendresubr
endswithr)r	handlerZpaths_to_checkr
ZqueryZresolves)rrrrr
impl5s(
	
z'normalize_path_middleware.<locals>.impl)r)rrrrr)rrrr
rscstfdd}|S)Nc	s-|jj||IdHSWdQRXdS)N)rZset_current_app)r	r)rrr
rUsz&_fix_request_current_app.<locals>.impl)r)rrr)rr
_fix_request_current_appSsr)rr)
rZaiohttp.web_exceptionsrZaiohttp.web_urldispatcherr__all__rrrrrrrr
<module>s3
Back to Directory File Manager