HEAD raises an exception
When a HEAD request is received by the server, it raises an exception and this makes our server's log noisy when bots and such hit it. Ideally, this would be handled with a 405 or passed to the process_request method with an indication that it's a HEAD instead of a GET to be handled there.
That's a valid feature request. Which server are you using? websockets.asyncio.server.serve?
At first sight, I would do it in the Sans-I/O layer so all implementations benefit from it, to be confirmed after looking at feasibility.
I'm using serve from websockets.sync.server but the issue can also be reproduced with the asyncio server in the example on the main page. Just start that up and hit with curl using -X HEAD and the exception happens.
Technically, replying with an upgrade request just like a GET would probably be fine (i.e. the response to a HEAD is supposed to be the same as a GET but without the body) but I don't know how useful that is in practice, so if it's easier to reply with a 405 METHOD_NOT_ALLOWED then that's great by me.
And on a related note, replying to a PUT/POST/DELETE/etc with a 405 instead of raising an exception would also be great. Most spiders use a HEAD or GET but there's plenty of bots out there doing all sorts of horrible things and handling those gracefully instead of with a raised exception would make my logs happier.
Yes it makes sense to return 405 on anything that isn't a GET.