[BUGFIX] Set content-length header to the end of output 69/54269/2
authorBenni Mack <benni@typo3.org>
Mon, 2 Oct 2017 23:34:02 +0000 (01:34 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 3 Oct 2017 11:15:35 +0000 (13:15 +0200)
Resolves: #76100
Resolves: #65719
Releases: master, 8.7
Change-Id: I2e389dd6ecb497a164a457230f106a64373c1907
Reviewed-on: https://review.typo3.org/54269
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php

index 3a923d1..b3b291f 100644 (file)
@@ -3632,17 +3632,6 @@ class TypoScriptFrontendController
                 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
             }
         }
-        // Send content-length header.
-        // Notice that all HTML content outside the length of the content-length header will be cut off!
-        // Therefore content of unknown length from included PHP-scripts and if admin users are logged
-        // in (admin panel might show...) or if debug mode is turned on, we disable it!
-        if (
-            (!isset($this->config['config']['enableContentLengthHeader']) || $this->config['config']['enableContentLengthHeader'])
-            && !$this->beUserLogin && !$GLOBALS['TYPO3_CONF_VARS']['FE']['debug']
-            && !$this->config['config']['debug'] && !$this->doWorkspacePreview()
-        ) {
-            header('Content-Length: ' . strlen($this->content));
-        }
     }
 
     /**
index f8427ec..fa4c612 100644 (file)
@@ -266,6 +266,17 @@ class RequestHandler implements RequestHandlerInterface
         if ($sendTSFEContent) {
             /** @var \TYPO3\CMS\Core\Http\Response $response */
             $response = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\Response::class);
+            // Send content-length header.
+            // Notice that all HTML content outside the length of the content-length header will be cut off!
+            // Therefore content of unknown length from included PHP-scripts and if admin users are logged
+            // in (admin panel might show...) or if debug mode is turned on, we disable it!
+            if (
+                (!isset($this->controller->config['config']['enableContentLengthHeader']) || $this->controller->config['config']['enableContentLengthHeader'])
+                && !$this->controller->beUserLogin && !$GLOBALS['TYPO3_CONF_VARS']['FE']['debug']
+                && !$this->controller->config['config']['debug'] && !$this->controller->doWorkspacePreview()
+            ) {
+                header('Content-Length: ' . strlen($this->controller->content));
+            }
             $response->getBody()->write($this->controller->content);
         }
         // Debugging Output