Skip to content

Commit a1720c5

Browse files
[PR #9911/4441d3c8 backport][3.11] Only construct the allowed_methods set once for a StaticResource (#9912)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 36d2bef commit a1720c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aiohttp/web_urldispatcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ def __init__(
580580
"HEAD", self._handle, self, expect_handler=expect_handler
581581
),
582582
}
583+
self._allowed_methods = set(self._routes)
583584

584585
def url_for( # type: ignore[override]
585586
self,
@@ -646,10 +647,10 @@ def set_options_route(self, handler: Handler) -> None:
646647
async def resolve(self, request: Request) -> _Resolve:
647648
path = request.rel_url.path_safe
648649
method = request.method
649-
allowed_methods = set(self._routes)
650650
if not path.startswith(self._prefix2) and path != self._prefix:
651651
return None, set()
652652

653+
allowed_methods = self._allowed_methods
653654
if method not in allowed_methods:
654655
return None, allowed_methods
655656

0 commit comments

Comments
 (0)