[BUGFIX] Fix non-302 redirects for PSR-7 response objects 02/51002/2
authorBenjamin Franzke <bfr@qbus.de>
Tue, 20 Dec 2016 06:26:42 +0000 (07:26 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Fri, 24 Feb 2017 07:59:25 +0000 (08:59 +0100)
commitcce7d774d926027ed32148f3709a4cac211a2612
treeb371e82568f95e4915aeb59583a61cd53b23347b
parentd9e0d47cd6bae94ce0f6faa0694e829a56121770
[BUGFIX] Fix non-302 redirects for PSR-7 response objects

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.

Change-Id: Ifa076e6393c6ed42d93959fe8c3a5b79cee145a4
Fixes: #79043
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/51002
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Marco Huber <mail@marco-huber.de>
Tested-by: Marco Huber <mail@marco-huber.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/Core/Bootstrap.php