forked from orbit-oss/flask
don't intercept 307/308 routing redirects
These don't change the request body, so the debug error is no longer relevant.
This commit is contained in:
parent
cb7cd1e79b
commit
c9a1f7ad65
3 changed files with 45 additions and 36 deletions
|
|
@ -1457,17 +1457,26 @@ class Flask(Scaffold):
|
|||
)
|
||||
|
||||
def raise_routing_exception(self, request: Request) -> "te.NoReturn":
|
||||
"""Exceptions that are recording during routing are reraised with
|
||||
this method. During debug we are not reraising redirect requests
|
||||
for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
|
||||
a different error instead to help debug situations.
|
||||
"""Intercept routing exceptions and possibly do something else.
|
||||
|
||||
In debug mode, intercept a routing redirect and replace it with
|
||||
an error if the body will be discarded.
|
||||
|
||||
With modern Werkzeug this shouldn't occur, since it now uses a
|
||||
308 status which tells the browser to resend the method and
|
||||
body.
|
||||
|
||||
.. versionchanged:: 2.1
|
||||
Don't intercept 307 and 308 redirects.
|
||||
|
||||
:meta private:
|
||||
:internal:
|
||||
"""
|
||||
if (
|
||||
not self.debug
|
||||
or not isinstance(request.routing_exception, RequestRedirect)
|
||||
or request.method in ("GET", "HEAD", "OPTIONS")
|
||||
or request.routing_exception.code in {307, 308}
|
||||
or request.method in {"GET", "HEAD", "OPTIONS"}
|
||||
):
|
||||
raise request.routing_exception # type: ignore
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue