ZF HTTP Status Code overwritten

Using code as below (in any call order):

    $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