-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: redirect status code #7445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: redirect status code #7445
Conversation
3ddc545 to
ae8ac2c
Compare
301 and 302 for a redirect without data (GET -> GET). GET, HEAD, (OPTIONS)? I hope you fix it, because the POST -> POST redirect in the current implementation will replace 307 or 308 with 303. |
Why? |
I think it will be fixed by this PR. |
system/HTTP/ResponseTrait.php
Outdated
| $code = ($_SERVER['REQUEST_METHOD'] !== 'GET') | ||
| ? 303 // reference: https://en.wikipedia.org/wiki/Post/Redirect/Get | ||
| : 307; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the HEAD and OPTIONS methods, there will be a 303 code, that is, a redirect with the GET method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There is a lot written in CI 3. But that doesn't mean it's right. |
Right or wrong is just a direction. If you want to go to the North Pole, it is right to go north. Yes, if there is a code in CI3, it does not means the code is right code. I just want you to show why your opinion is right. |
|
I will repeat what I said above.
Regarding code CI3. The HEAD and OPTIONS methods are not GET, which means that they will have a 303 response code, but this makes no sense when redirecting using the GET method. For a GET request, it makes no sense to use 307 (308) response codes, since a GET request does not imply a request body. It makes more sense to use 302 (301). Conclusion. For non-GET methods, the behavior will not change. Since they are already redirected to 303. |
ae8ac2c to
f5bbe1a
Compare
|
Maybe we could add https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections as a reference for IMO this is a good change. |
d79bacd to
31bdd79
Compare
|
Added docs. |
For consistency. Other methods use null by default.
The `to()` is not a function.
31bdd79 to
1c3a3b7
Compare
|
Rebased to resolve conflicts, and tweaks the added note (the last 3 commits). |
|
@michalsn Thank you. |
Description
With this PR, if you specify status code for redirect, the code is surely used in the response.
$routes->addRedirect()specifies 302 by default. So 302 will be used by default.nullfor$codeinRedirectResponse::route()(For consistency)Ref #3057
Checklist: