[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('http://www.domain.com/path', true);


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:, server: domain.local, request: "POST /login HTTP/1.1", upstream: "fastcgi://", host: "domain.local", referrer: "http://domain.local/login"

I think, reason of error is a string concatenation like

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

somewhere in Phalcon internal code


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('http://www.domain.com/path', true);

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) "http://www.domain.com/path" } }

edited Feb '18

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