/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
aiohttp
/
/usr/local/lib64/python3.6/site-packages/aiohttp
mkdir
upload
Name
Size
Mode
Actions
.hash/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
5505
0644
edit
dl
rm
base_protocol.py
2741
0644
edit
dl
rm
client.py
45872
0644
edit
dl
rm
client_exceptions.py
9270
0644
edit
dl
rm
client_proto.py
8170
0644
edit
dl
rm
client_reqrep.py
37151
0644
edit
dl
rm
client_ws.py
10516
0644
edit
dl
rm
connector.py
51367
0644
edit
dl
rm
cookiejar.py
13768
0644
edit
dl
rm
formdata.py
6106
0644
edit
dl
rm
hdrs.py
4724
0644
edit
dl
rm
helpers.py
26527
0644
edit
dl
rm
http.py
1800
0644
edit
dl
rm
http_exceptions.py
2715
0644
edit
dl
rm
http_parser.py
35434
0644
edit
dl
rm
http_websocket.py
25299
0644
edit
dl
rm
http_writer.py
5933
0644
edit
dl
rm
locks.py
1136
0644
edit
dl
rm
log.py
325
0644
edit
dl
rm
multipart.py
32313
0644
edit
dl
rm
payload.py
13632
0644
edit
dl
rm
payload_streamer.py
2112
0644
edit
dl
rm
py.typed
7
0644
edit
dl
rm
pytest_plugin.py
11772
0644
edit
dl
rm
resolver.py
5092
0644
edit
dl
rm
streams.py
20758
0644
edit
dl
rm
tcp_helpers.py
961
0644
edit
dl
rm
test_utils.py
21434
0644
edit
dl
rm
tracing.py
15177
0644
edit
dl
rm
typedefs.py
1766
0644
edit
dl
rm
web.py
18081
0644
edit
dl
rm
web_app.py
17170
0644
edit
dl
rm
web_exceptions.py
10098
0644
edit
dl
rm
web_fileresponse.py
10784
0644
edit
dl
rm
web_log.py
7557
0644
edit
dl
rm
web_middlewares.py
4137
0644
edit
dl
rm
web_protocol.py
22399
0644
edit
dl
rm
web_request.py
28187
0644
edit
dl
rm
web_response.py
27471
0644
edit
dl
rm
web_routedef.py
6152
0644
edit
dl
rm
web_runner.py
11157
0644
edit
dl
rm
web_server.py
2050
0644
edit
dl
rm
web_urldispatcher.py
39483
0644
edit
dl
rm
web_ws.py
17144
0644
edit
dl
rm
worker.py
8755
0644
edit
dl
rm
_cparser.pxd
4318
0644
edit
dl
rm
_find_header.pxd
68
0644
edit
dl
rm
_headers.pxi
2007
0644
edit
dl
rm
_helpers.cpython-36m-x86_64-linux-gnu.so
309600
0755
edit
dl
rm
_helpers.pyi
202
0644
edit
dl
rm
_helpers.pyx
1049
0644
edit
dl
rm
_http_parser.cpython-36m-x86_64-linux-gnu.so
2218424
0755
edit
dl
rm
_http_parser.pyx
28058
0644
edit
dl
rm
_http_writer.cpython-36m-x86_64-linux-gnu.so
292576
0755
edit
dl
rm
_http_writer.pyx
4575
0644
edit
dl
rm
_websocket.cpython-36m-x86_64-linux-gnu.so
113776
0755
edit
dl
rm
_websocket.pyx
1561
0644
edit
dl
rm
__init__.py
6870
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/aiohttp/web_middlewares.py
(4137B)
import re from typing import TYPE_CHECKING, Awaitable, Callable, Tuple, Type, TypeVar from .typedefs import Handler from .web_exceptions import HTTPPermanentRedirect, _HTTPMove from .web_request import Request from .web_response import StreamResponse from .web_urldispatcher import SystemRoute __all__ = ( "middleware", "normalize_path_middleware", ) if TYPE_CHECKING: # pragma: no cover from .web_app import Application _Func = TypeVar("_Func") async def _check_request_resolves(request: Request, path: str) -> Tuple[bool, Request]: alt_request = request.clone(rel_url=path) match_info = await request.app.router.resolve(alt_request) alt_request._match_info = match_info if match_info.http_exception is None: return True, alt_request return False, request def middleware(f: _Func) -> _Func: f.__middleware_version__ = 1 # type: ignore[attr-defined] return f _Middleware = Callable[[Request, Handler], Awaitable[StreamResponse]] def normalize_path_middleware( *, append_slash: bool = True, remove_slash: bool = False, merge_slashes: bool = True, redirect_class: Type[_HTTPMove] = HTTPPermanentRedirect, ) -> _Middleware: """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. """ correct_configuration = not (append_slash and remove_slash) assert correct_configuration, "Cannot both remove and append slash" @middleware async def impl(request: Request, handler: Handler) -> StreamResponse: if isinstance(request.match_info.route, SystemRoute): paths_to_check = [] if "?" in request.raw_path: path, query = request.raw_path.split("?", 1) query = "?" + query else: query = "" path = request.raw_path if merge_slashes: paths_to_check.append(re.sub("//+", "/", path)) if append_slash and not request.path.endswith("/"): paths_to_check.append(path + "/") if remove_slash and request.path.endswith("/"): paths_to_check.append(path[:-1]) if merge_slashes and append_slash: paths_to_check.append(re.sub("//+", "/", path + "/")) if merge_slashes and remove_slash: merged_slashes = re.sub("//+", "/", path) paths_to_check.append(merged_slashes[:-1]) for path in paths_to_check: path = re.sub("^//+", "/", path) # SECURITY: GHSA-v6wp-4m6f-gcjg resolves, request = await _check_request_resolves(request, path) if resolves: raise redirect_class(request.raw_path + query) return await handler(request) return impl def _fix_request_current_app(app: "Application") -> _Middleware: @middleware async def impl(request: Request, handler: Handler) -> StreamResponse: with request.match_info.set_current_app(app): return await handler(request) return impl
Save
cmd:
run