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)
  • Loading branch information
bdraco authored Nov 19, 2024
1 parent 4e8324e commit 9916d32
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 @@ -557,7 +557,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 @@ -624,7 +623,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 9916d32

Please sign in to comment.