Skip to content
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

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Fix. redirect custom HTTP Code not work #3057

merged 1 commit into from
Jun 8, 2020

Conversation

nyufeng
Copy link
Contributor

@nyufeng nyufeng commented Jun 2, 2020

From #3041
Thanks @MichalPB1 's suggest

Redirect HTTP Code can't work. when method is get, it always set as 307.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@MGatner
Copy link
Member

MGatner commented Jun 3, 2020

@Instrye it looks like there was more discussion on the issue since this PR. Is this ready for review?

@nyufeng
Copy link
Contributor Author

nyufeng commented Jun 8, 2020

@Instrye it looks like there was more discussion on the issue since this PR. Is this ready for review?

Yes,It ready.

@lonnieezell lonnieezell merged commit ba8aa10 into codeigniter4:develop Jun 8, 2020
@nyufeng nyufeng deleted the fix-redirection branch September 3, 2020 06:43
$this->codeigniter->useSafeOutput(true)->run();
ob_get_clean();
$response = $this->getPrivateProperty($this->codeigniter, 'response');
$this->assertEquals('303', $response->getStatusCode());
Copy link
Member

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.

Copy link
Member

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$code = ($_SERVER['REQUEST_METHOD'] !== 'GET') ? 303 : ($code === 302 ? 307 : $code);

Copy link
Member

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 ?

Copy link
Collaborator

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.

@kenjis kenjis mentioned this pull request Apr 20, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants