Skip to content

Commit

Permalink
[PR #9972/9916d329 backport][3.11] Revert "Only construct the `allowe…
Browse files Browse the repository at this point in the history
…d_methods` `set` once for a `StaticResource`" (#9973)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Nov 19, 2024
1 parent 454f914 commit 39f6832
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 39f6832

Please sign in to comment.