Respond 405 for unsupported methods instead of server error

This commit is contained in:
Unrud 2020-09-12 20:23:45 +02:00
parent 9d25cc6c0a
commit 6091bd46a3

View File

@ -224,7 +224,10 @@ class Application(
logger.debug("Sanitized path: %r", path) logger.debug("Sanitized path: %r", path)
# Get function corresponding to method # Get function corresponding to method
function = getattr(self, "do_%s" % environ["REQUEST_METHOD"].upper()) function = getattr(
self, "do_%s" % environ["REQUEST_METHOD"].upper(), None)
if not function:
return response(*httputils.METHOD_NOT_ALLOWED)
# If "/.well-known" is not available, clients query "/" # If "/.well-known" is not available, clients query "/"
if path == "/.well-known" or path.startswith("/.well-known/"): if path == "/.well-known" or path.startswith("/.well-known/"):