Skip to content

Commit

Permalink
Only construct the allowed_methods set once for a StaticResource (
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 15, 2024
1 parent 2249f2d commit 4441d3c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ def __init__(
"HEAD", self._handle, self, expect_handler=expect_handler
),
}
self._allowed_methods = set(self._routes)

def url_for( # type: ignore[override]
self,
Expand Down Expand Up @@ -620,10 +621,10 @@ def set_options_route(self, handler: Handler) -> None:
async def resolve(self, request: Request) -> _Resolve:
path = request.rel_url.path_safe
method = request.method
allowed_methods = set(self._routes)
if not path.startswith(self._prefix2) and path != self._prefix:
return None, set()

allowed_methods = self._allowed_methods
if method not in allowed_methods:
return None, allowed_methods

Expand Down

0 comments on commit 4441d3c

Please sign in to comment.