http method validation

This commit is contained in:
IML 2021-06-06 01:06:28 +09:00
parent aac67289e5
commit 5324bac0d2

View file

@ -1083,6 +1083,19 @@ class Flask(Scaffold):
# Add the required methods now.
methods |= required_methods
# Check HTTP method
supported_http_methods = {
"GET", "POST", "PUT", "PATCH", "DELETE",
"HEAD", "CONNECT", "OPTIONS", "TRACE",
"COPY", "LINK", "UNLINK", "PURGE",
"LOCK", "UNLOCK", "PROFIND", "VIEW"
}
for item in methods:
if item not in supported_http_methods:
raise TypeError(
f"'{item}' method is not specified in HTTP."
)
rule = self.url_rule_class(rule, methods=methods, **options)
rule.provide_automatic_options = provide_automatic_options # type: ignore