Skip to content
Myr

redirect defaults to 303

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent eb58d86 · Browse files · 4 files+14 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+14 added−3 removed

  • other:+14 added−3 removed

4 files+14 added−3 removed

modified:docs/api.rst+1 added-1 removed
594 unmodified lines
595This specifies that ``/users/`` will be the URL for page one and596``/users/page/N`` will be the URL for page ``N``.597598If a URL contains a default value, it will be redirected to its simpler599form with a 301 redirect. In the above example, ``/users/page/1`` will599form with a 308 redirect. In the above example, ``/users/page/1`` will600be redirected to ``/users/``. If your route handles ``GET`` and ``POST``601requests, make sure the default route only handles ``GET``, as redirects602can't preserve form data. ::603
105 unmodified lines
modified:src/flask/sansio/app.py+4 added-1 removed
930 unmodified lines
931 .. versionadded:: 0.10932 """933 return False934935 def redirect(self, location: str, code: int = 302) -> BaseResponse:935 def redirect(self, location: str, code: int = 303) -> BaseResponse:936 """Create a redirect response object.937938 This is called by :func:`flask.redirect`, and can be called939 directly as well.940941 :param location: The URL to redirect to.942 :param code: The status code for the redirect.943944 .. versionchanged:: 3.2945 ``code`` defaults to ``303`` instead of ``302``.946947 .. versionadded:: 2.2948 Moved from ``flask.redirect``, which calls this method.949 """950 return _wz_redirect(
59 unmodified lines
modified:src/flask/helpers.py+4 added-1 removed
237 unmodified lines
238 )239240241def redirect(242 location: str, code: int = 302, Response: type[BaseResponse] | None = None242 location: str, code: int = 303, Response: type[BaseResponse] | None = None243) -> BaseResponse:244 """Create a redirect response object.245246 If :data:`~flask.current_app` is available, it will use its
4 unmodified lines
251 :param code: The status code for the redirect.252 :param Response: The response class to use. Not used when253 ``current_app`` is active, which uses ``app.response_class``.254255 .. versionchanged:: 3.2256 ``code`` defaults to ``303`` instead of ``302``.257258 .. versionadded:: 2.2259 Calls ``current_app.redirect`` if available instead of always260 using Werkzeug's default ``redirect``.261 """
377 unmodified lines
modified:CHANGES.rst+5 added
14 unmodified lines
15 shows a deprecation warning, and will continue to work during the16 deprecation period. :issue:`5815`17- ``template_filter``, ``template_test``, and ``template_global`` decorators18 can be used without parentheses. :issue:`5729`19- ``redirect`` returns a ``303`` status code by default instead of ``302``.20 This tells the client to always switch to ``GET``, rather than only21 switching ``POST`` to ``GET``. This preserves the current behavior of22 ``GET`` and ``POST`` redirects, and is also correct for frontend libraries23 such as HTMX. :issue:`5895`242526Version 3.1.227-------------
1622 unmodified lines