-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 custom HTTP Code not work #3057
Conversation
@Instrye it looks like there was more discussion on the issue since this PR. Is this ready for review? |
Yes,It ready. |
$this->codeigniter->useSafeOutput(true)->run(); | ||
ob_get_clean(); | ||
$response = $this->getPrivateProperty($this->codeigniter, 'response'); | ||
$this->assertEquals('303', $response->getStatusCode()); |
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.
Why is this code changed to 303?
The route sets the status code 301.
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.
I sent a PR to fix the behavior: #7445
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.
CodeIgniter4/system/HTTP/ResponseTrait.php
Line 519 in e151d3a
$code = ($_SERVER['REQUEST_METHOD'] !== 'GET') ? 303 : ($code === 302 ? 307 : $code); |
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.
I mean, it should be 301 ?
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.
Essentially it should be 301, but the handler is written so that the custom response code is ignored.
From #3041
Thanks @MichalPB1 's suggest
Redirect HTTP Code can't work. when method is get, it always set as 307.
Checklist: