This exception is raised in debug mode if a routing redirect would cause the browser to drop the method or body. This happens when method is not GET, HEAD or OPTIONS and the status code is not 307 or 308.
| 48 | |
| 49 | |
| 50 | class FormDataRoutingRedirect(AssertionError): |
| 51 | """This exception is raised in debug mode if a routing redirect |
| 52 | would cause the browser to drop the method or body. This happens |
| 53 | when method is not GET, HEAD or OPTIONS and the status code is not |
| 54 | 307 or 308. |
| 55 | """ |
| 56 | |
| 57 | def __init__(self, request: Request) -> None: |
| 58 | exc = request.routing_exception |
| 59 | assert isinstance(exc, RequestRedirect) |
| 60 | buf = [ |
| 61 | f"A request was sent to '{request.url}', but routing issued" |
| 62 | f" a redirect to the canonical URL '{exc.new_url}'." |
| 63 | ] |
| 64 | |
| 65 | if f"{request.base_url}/" == exc.new_url.partition("?")[0]: |
| 66 | buf.append( |
| 67 | " The URL was defined with a trailing slash. Flask" |
| 68 | " will redirect to the URL with a trailing slash if it" |
| 69 | " was accessed without one." |
| 70 | ) |
| 71 | |
| 72 | buf.append( |
| 73 | " Send requests to the canonical URL, or use 307 or 308 for" |
| 74 | " routing redirects. Otherwise, browsers will drop form" |
| 75 | " data.\n\n" |
| 76 | "This exception is only raised in debug mode." |
| 77 | ) |
| 78 | super().__init__("".join(buf)) |
| 79 | |
| 80 | |
| 81 | def attach_enctype_error_multidict(request: Request) -> None: |
no outgoing calls
no test coverage detected