All redirect status codes (e.g. 201,301,303,307) are incorrectly
sent as 302.
We need to set the response code before setting the Location header,
as a call to header('Location: ...'); sets the response code
implicitly to 302 (unless it has already been set to 201 or 3xx) [1].
By settings the status code/header first, header('Location: ..') will
not change the status code, if the PSR-7 response object contains a
proper redirect status code.
[1] http://php.net/manual/en/function.header.php
The second special case is the "Location:" header.
Not only does it send this header back to the browser, but it also
returns a REDIRECT (302) status code to the browser unless the 201
or a 3xx status code has already been set.