Skip to content

Commit 39f6832

Browse files
[PR #9972/9916d329 backport][3.11] Revert "Only construct the allowed_methods set once for a StaticResource" (#9973)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 454f914 commit 39f6832

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGES/9972.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Reverted an optimization to avoid rebuilding the allowed methods for ``StaticResource`` on every request -- by :user:`bdraco`.
2+
3+
``aiohttp-cors`` needs to be able to modify the allowed methods at run time via this internal.

aiohttp/web_urldispatcher.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ def __init__(
580580
"HEAD", self._handle, self, expect_handler=expect_handler
581581
),
582582
}
583-
self._allowed_methods = set(self._routes)
584583

585584
def url_for( # type: ignore[override]
586585
self,
@@ -650,7 +649,7 @@ async def resolve(self, request: Request) -> _Resolve:
650649
if not path.startswith(self._prefix2) and path != self._prefix:
651650
return None, set()
652651

653-
allowed_methods = self._allowed_methods
652+
allowed_methods = set(self._routes)
654653
if method not in allowed_methods:
655654
return None, allowed_methods
656655

0 commit comments

Comments
 (0)