Browse Source

fix: handle routes without methods in head helper

pull/15356/head
Herrtian 2 months ago
parent
commit
b141423b13
  1. 3
      fastapi/routing.py

3
fastapi/routing.py

@ -1157,10 +1157,11 @@ class APIRoute(routing.Route):
) -> bool:
"""Check if this is a HEAD request that should be served by a GET route."""
route_methods = methods if methods is not None else self.methods
if not route_methods:
return False
return (
scope.get("type") == "http"
and scope.get("method") == "HEAD"
and bool(route_methods)
and "GET" in route_methods
and "HEAD" not in route_methods
)

Loading…
Cancel
Save