From 5324bac0d284d9ab32ab36f3cb317cb9d816f2bc Mon Sep 17 00:00:00 2001 From: IML Date: Sun, 6 Jun 2021 01:06:28 +0900 Subject: [PATCH] http method validation --- src/flask/app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/flask/app.py b/src/flask/app.py index cacb40a5..794ae095 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -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