Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #9972/9916d329 backport][3.11] Revert "Only construct the allowed_methods set once for a StaticResource" #9973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading