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

Set HTTP Version 1.1 on Post/Redirect/Get (PRG) #932

Closed
wants to merge 1 commit into from

Conversation

natanfelles
Copy link
Contributor

Fix #769
Fix #931

@natanfelles
Copy link
Contributor Author

Inside a Controller the Validation Errors are not accessible in $validator. But is possible to get the last errors (_ci_validation_errors flashdata) with \Config\Services::validation()->getErrors().

What about after redirect()->back()->withInput() use the shared instance of the Validation with the $validator? Then enable to get the errors with $this->validator->getErrors().


This could be done in the Controller constructor:

$this->validator = Services::validation();

That will load the Validation every call, maybe check if has _ci_validation_errors flashdata (what could say if is coming back).

@lonnieezell
Copy link
Member

A couple of things:

We shouldn't fix the HTTP version - 1.0 is theoretically possible to run into, and 2.0 is the new hotness. I'm pretty sure I was checking the incoming version at some point, but will have to check that later today when I'm not working the day job. We should be matching the incoming HTTP version or defaulting to 1.1.

The validator is a subject for a different thread, but the obvious problem being the values wouldn't survive the redirect. Additionally, I don't believe the validator is necessarily shared between models, and not 100% sure if that would be a good thing.

@@ -573,6 +573,7 @@ public function redirect(string $uri, string $method = 'auto', int $code = null)
{
if (isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The version 1.1 is checked here. Maybe remove the HTTP/ and get the numbers to set below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the conditional forces to be 1.1...

@lonnieezell
Copy link
Member

The thing to check first, I believe, is that the HTTP status is being sent correctly in the request, and that CI is copying that forward in to the response. This should happen in CodeIgniter.php.

If that's being set correctly there, it should already exist at the time of the redirect. But, yes, it looks like it needs to get checked properly during the redirect code.

@natanfelles
Copy link
Contributor Author

Thank you! 😄

@natanfelles natanfelles deleted the redirects branch February 16, 2018 05:46
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.

2 participants