* Allow for custom head method in HTTPEndpoint
Fix for https://github.com/encode/starlette/issues/1221
* Fix formatting
* Allow custom head method in HTTPEndpoint
Co-authored-by: theblazehen <theblazehen@gmail.com>
async def dispatch(self) -> None:
request = Request(self.scope, receive=self.receive)
- handler_name = "get" if request.method == "HEAD" else request.method.lower()
+ handler_name = (
+ "get"
+ if request.method == "HEAD" and not hasattr(self, "head")
+ else request.method.lower()
+ )
+
handler = getattr(self, handler_name, self.method_not_allowed)
is_async = asyncio.iscoroutinefunction(handler)
if is_async: