diff --git a/CHANGES/9972.bugfix.rst b/CHANGES/9972.bugfix.rst new file mode 100644 index 00000000000..d8d69d09044 --- /dev/null +++ b/CHANGES/9972.bugfix.rst @@ -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. diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index e4d43514ebe..025962bc594 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -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, @@ -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