http method validation
This commit is contained in:
parent
aac67289e5
commit
5324bac0d2
1 changed files with 13 additions and 0 deletions
|
|
@ -1083,6 +1083,19 @@ class Flask(Scaffold):
|
||||||
# Add the required methods now.
|
# Add the required methods now.
|
||||||
methods |= required_methods
|
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 = self.url_rule_class(rule, methods=methods, **options)
|
||||||
rule.provide_automatic_options = provide_automatic_options # type: ignore
|
rule.provide_automatic_options = provide_automatic_options # type: ignore
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue