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
#9911)

(cherry picked from commit 4441d3c)
  • Loading branch information
bdraco authored and patchback[bot] committed Nov 15, 2024
1 parent 36d2bef commit 5344341
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 @@ -580,6 +580,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 @@ -646,10 +647,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 5344341

Please sign in to comment.