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

Redirects not working #931

Closed
natanfelles opened this issue Feb 8, 2018 · 2 comments
Closed

Redirects not working #931

natanfelles opened this issue Feb 8, 2018 · 2 comments

Comments

@natanfelles
Copy link
Contributor

Trying to use redirect()->back(); after an POST request the HTTP Header are show on the page body, like:

HTTP/ 303 See Other
Host: localhost:8080
Date: Thu, 08 Feb 2018 09:56:58 -0200
Connection: close
X-Powered-By: PHP/7.2.2-1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Cache-control: no-store, max-age=0, no-cache
Content-Type: text/html; charset=UTF-8
Location: http://localhost:8080/login

The motive is that the HTTP Version is not set.

Looking on system/HTTP/Response.php, line 597, the sendHeaders() is called. And adding $this->setProtocolVersion('1.1'); just before could solve this issue.

But I'm not sure if is the correct place to set it.

@natanfelles
Copy link
Contributor Author

natanfelles commented Feb 20, 2018

redirect()->back(); continues not working. Seems that the RedirectResponse is not getting the shared instance of the Response set in the CodeIgniter. Having the following error:

Return value of CodeIgniter\HTTP\Message::getProtocolVersion() must be of the type string, null returned

  • BASEPATH/HTTP/Message.php at line 363

In Common.php:768:

function redirect(string $uri=null)
{
	$response = Services::redirectResponse(null, true);
	var_dump($response);exit;

	if (! empty($uri))
	{
		return $response->to($uri);
	}

	return $response;
}
protected 'protocolVersion' => null

@natanfelles natanfelles reopened this Feb 20, 2018
@natanfelles
Copy link
Contributor Author

A temporary solution was to add the following in the Response constructor:

$request = \Config\Services::request();
$this->setProtocolVersion($request->getProtocolVersion());

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

No branches or pull requests

1 participant