We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

[bug] Response->redirect() throws 502

Response->redirect() function has 3 arguments. If we provide second argument without third, we can see Phalcon`s crash.

For example (in Action):

return $this->response->redirect('https://www.domain.com/path', true);


98.9k

Do you have the latest version? I can't reproduce the bug.

Also, remember that bugs must be reported on Github: https://github.com/phalcon/cphalcon/issues

edited Oct '14

My working version is not so old (last commit is 1cb203874fb4ab39abc29b92dc13856381caea78 on 1.2.0 branch)

In log we can see:

2013/06/10 23:51:39 [error] 6645#0: *1434 upstream sent invalid status "Redirect" while reading response header from upstream, client: 127.0.0.1, server: domain.local, request: "POST /login HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.local", referrer: "https://domain.local/login"

I think, reason of error is a string concatenation like

header('HTTP/1.1 ' . null . ' Redirect');

somewhere in Phalcon internal code



98.9k

If the developer did not pass a http status code it uses 302: https://github.com/phalcon/cphalcon/blob/master/ext/http/response.c#L539

If you run something like this:

$r = new Phalcon\Http\Response();
$r->redirect('https://www.domain.com/path', true);
var_dump($r->getHeaders());

You'll see:

object(Phalcon\Http\Response\Headers)#2 (1) { ["_headers":protected]=> array(3) { ["HTTP/1.1 302 Redirect"]=> NULL ["Status"]=> string(12) "302 Redirect" ["Location"]=> string(26) "https://www.domain.com/path" } }


2.6k
edited Feb '18

The same problem, how to resolve it? redirect to another url after delete a record from db, it return 502