Skip to content

Commit 31bdd79

Browse files
committed
docs: add docs
1 parent 3f7f4c9 commit 31bdd79

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

user_guide_src/source/changelogs/v4.3.4.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ Release Date: Unreleased
1212
BREAKING
1313
********
1414

15+
Behavior Changes
16+
================
17+
18+
.. _v434-redirect-status-code:
19+
20+
Redirect Status Code
21+
--------------------
22+
23+
- Due to a bug, in previous versions, when using HTTP/1.1 or later the status
24+
code of the actual redirect response might be changed even if a status code was
25+
specified. For example, for a GET request, 302 would change to 307; for a POST
26+
request, 307 and 302 would change to 303.
27+
- Starting with this version, if you specify a status code in
28+
:ref:`redirect <response-redirect-status-code>`, that code will always be used
29+
in the response.
30+
- The default code for GET requests has been corrected from 307 to 302 when using
31+
HTTP/1.1 or later.
32+
- The default code for HEAD and OPTIONS requests has been corrected from 303 to
33+
307 when using HTTP/1.1 or later.
34+
- In ``$routes->addRedirect()``, 302 is specified by default. Therefor 302 will
35+
always be used when you don't specify a status code. In previous versions,
36+
302 might be changed.
37+
1538
Message Changes
1639
***************
1740

user_guide_src/source/installation/upgrade_434.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Mandatory File Changes
1818
Breaking Changes
1919
****************
2020

21+
Redirect Status Code
22+
====================
23+
24+
- Due to a bug fix, the status codes of redirects may be changed. See
25+
:ref:`ChangeLog v4.3.4 <v434-redirect-status-code>` and if the code is not
26+
what you want, :ref:`specify status codes <response-redirect-status-code>`.
27+
2128
Breaking Enhancements
2229
*********************
2330

user_guide_src/source/outgoing/response.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ When you want to redirect back, use ``redirect()->back()``:
109109
It takes a visitor to "the last page viewed during the Session" when the Session is available.
110110
If the Session hasn’t been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used.
111111

112+
.. _response-redirect-status-code:
113+
114+
Redirect Status Code
115+
--------------------
116+
117+
The default HTTP status code for GET requests is 302. However, when using HTTP/1.1
118+
or later, 303 is used for POST/PUT/DELETE requests and 307 for all other requests.
119+
120+
You can specify the status code:
121+
122+
.. literalinclude:: ./response/032.php
123+
:lines: 2-
124+
125+
.. note:: Due to a bug, in v4.3.3 or previous versions, the status code of the
126+
actual redirect response might be changed even if a status code was specified.
127+
See :ref:`ChangeLog v4.3.4 <v434-redirect-status-code>`.
128+
129+
If you don't know HTTP status code for redirection, it is recommended to read
130+
`Redirections in HTTP <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections>`_.
131+
112132
.. _force-file-download:
113133

114134
Force File Download
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Redirect to a URI path relative to baseURL with status code 301.
4+
return redirect()->to('admin/home', 301);
5+
6+
// Redirect to a route with status code 308.
7+
return redirect()->route('user_gallery', [], 308);
8+
9+
// Redirect back with status code 302.
10+
return redirect()->back(302);

0 commit comments

Comments
 (0)