[BUGFIX] PSR-7: Only send headers if no other headers are prepared 49/42049/2
authorBenjamin Mack <benni@typo3.org>
Tue, 28 Jul 2015 15:43:29 +0000 (17:43 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 28 Jul 2015 16:08:46 +0000 (18:08 +0200)
The PSR-7 functionality to send the headers is now only
in use if the headers haven't been sent already or no other function
has declared any other headers before (e.g. Extbase).

This is an intermediate solution until Extbase and TSFE are fully
using the PSR-7 functionality.

Releases: master
Resolves: #68506
Change-Id: I32b1266b020fd3f36fa4676d8414b0770e96208f
Reviewed-on: http://review.typo3.org/42049
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Classes/Core/Bootstrap.php

index f9a692d..3612776 100644 (file)
@@ -296,11 +296,12 @@ class Bootstrap {
         */
        protected function sendResponse() {
                if ($this->response instanceof \Psr\Http\Message\ResponseInterface) {
-                       if (!headers_sent()) {
+                       // Send the response headers only if no header was sent before
+                       if (!headers_sent() && empty(headers_list())) {
                                foreach ($this->response->getHeaders() as $name => $values) {
                                        header($name . ': ' . implode(', ', $values), FALSE);
                                }
-                               // send the response type
+                               // Send the response type
                                header('HTTP/' . $this->response->getProtocolVersion() . ' ' . $this->response->getStatusCode() . ' ' . $this->response->getReasonPhrase());
                        }
                        echo $this->response->getBody()->__toString();