Skip to content

Commit

Permalink
Revert "Only construct the allowed_methods set once for a `Static…
Browse files Browse the repository at this point in the history
…Resource`" (#9972)

(cherry picked from commit 9916d32)
  • Loading branch information
bdraco authored and patchback[bot] committed Nov 19, 2024
1 parent c451b24 commit 0a75df3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES/9972.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reverted an optimization to avoid rebuilding the allowed methods for ``StaticResource`` on every request -- by :user:`bdraco`.

``aiohttp-cors`` needs to be able to modify the allowed methods at run time via this internal.
3 changes: 1 addition & 2 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ 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 @@ -650,7 +649,7 @@ async def resolve(self, request: Request) -> _Resolve:
if not path.startswith(self._prefix2) and path != self._prefix:
return None, set()

allowed_methods = self._allowed_methods
allowed_methods = set(self._routes)
if method not in allowed_methods:
return None, allowed_methods

Expand Down

0 comments on commit 0a75df3

Please sign in to comment.