Merge pull request #3315 from linchiwei123/cleanup

clean up outdated code
This commit is contained in:
David Lord 2019-07-25 11:33:36 -07:00 committed by GitHub
commit b7f6fae9b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,6 @@ from werkzeug.exceptions import BadRequestKeyError
from werkzeug.exceptions import default_exceptions
from werkzeug.exceptions import HTTPException
from werkzeug.exceptions import InternalServerError
from werkzeug.exceptions import MethodNotAllowed
from werkzeug.routing import BuildError
from werkzeug.routing import Map
from werkzeug.routing import RequestRedirect
@ -2000,17 +1999,7 @@ class Flask(_PackageBoundObject):
.. versionadded:: 0.7
"""
adapter = _request_ctx_stack.top.url_adapter
if hasattr(adapter, "allowed_methods"):
methods = adapter.allowed_methods()
else:
# fallback for Werkzeug < 0.7
methods = []
try:
adapter.match(method="--")
except MethodNotAllowed as e:
methods = e.valid_methods
except HTTPException:
pass
methods = adapter.allowed_methods()
rv = self.response_class()
rv.allow.update(methods)
return rv