zendframework/zf2 — pull request #3661 by fantasticjamieburns (2013-02-04 06:18:55+00:00)
Title: ZF HTTP Status Code overwritten

Using code like:

$response->setStatusCode(HttpResponse::STATUS_CODE_202);
$response->getHeaders()->addHeaderLine('Location', $location);

In a controller does not work because PHP's header() function sets a 302 code whenever a Location header is sent.

By sending the ZF "status header line" last we can make sure that the correct code is sent to the client. Unfortunately this cannot be tested explicitly because xdebug_get_headers() does not seem to return the status header.

Ref: http://php.net/manual/en/function.header.php