diff --git a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml index d90d8ec43751696139d39cf639c217839448237a..393f7b3841da966885710258a7c33ebce67b0356 100644 --- a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml +++ b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml @@ -381,7 +381,7 @@ FE: description: 'Additional relative paths (comma-list) to allow TypoScript resources be in. Should be prepended with ''/''. If not, then any path where the first part is like this path will match. That is: ''myfolder/ , myarchive'' will match eg. ''myfolder/'', ''myarchive/'', ''myarchive_one/'', ''myarchive_2/'' ... No check is done to see if this directory actually exists in the root of the site. Paths are matched by simply checking if these strings equals the first part of any TypoScript resource filepath. (See class template, function init() in <code>\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser)</code>' debug: type: bool - description: 'If enabled, additional information (if the page was cached, and how long the processing took) as HTML comments is rendered at the end of each frontend request. This can also be enabled/disabled via the TypoScript option <code>config.debug = 0</code>.' + description: 'If enabled, the total parsetime of the page is added as HTTP response header "X-TYPO3-Parsetime". This can also be enabled/disabled via the TypoScript option <code>config.debug = 0</code>.' compressionLevel: type: int description: 'Determines output compression of FE output. Makes output smaller but slows down the page generation depending on the compression level. Requires zlib in your PHP installation. Range 1-9, where 1 is least compression and 9 is greatest compression. ''true'' as value will set the compression based on the PHP default settings (usually 5). Suggested and most optimal value is 5.' diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-82419-SendFrontendDebugInformationAsHTTPResponseHeader.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-82419-SendFrontendDebugInformationAsHTTPResponseHeader.rst new file mode 100644 index 0000000000000000000000000000000000000000..bde581ae06f4c7c0ffe6d6b866875a4ace2f6dbc --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-82419-SendFrontendDebugInformationAsHTTPResponseHeader.rst @@ -0,0 +1,25 @@ +.. include:: ../../Includes.txt + +========================================================================= +Feature: #82419 - Send Frontend Debug Information as HTTP Response Header +========================================================================= + +See :issue:`82419` + +Description +=========== + +When setting `config.debug=1` or `$TYPO3_CONF_VARS[FE][debug]` the parse time is now sent as HTTP +response header "X-TYPO3-Parsetime" instead of HTML comments. + + +Impact +====== + +This ensures that non-HTML-content (e.g. JSON output) does not break when having debugging for the +Frontend enabled. + +If you look for the parse time of a frontend request, this can now easily be shown via +`curl -I https://mydomain.com` or in the developer toolbar of the browser. + +.. index:: Frontend \ No newline at end of file diff --git a/typo3/sysext/frontend/Classes/Http/RequestHandler.php b/typo3/sysext/frontend/Classes/Http/RequestHandler.php index 7215158f9fea408d878bd0f651d8bb39a7a99b62..58c4051078b4e4dd7372f3bb72252fd875ca908c 100644 --- a/typo3/sysext/frontend/Classes/Http/RequestHandler.php +++ b/typo3/sysext/frontend/Classes/Http/RequestHandler.php @@ -229,16 +229,22 @@ class RequestHandler implements RequestHandlerInterface } // Store session data for fe_users $this->controller->storeSessionData(); + + // Create a Response object when sending content + if ($sendTSFEContent) { + $response = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\Response::class); + } + // Statistics $GLOBALS['TYPO3_MISC']['microtime_end'] = microtime(true); - if ($this->controller->isOutputting()) { + if ($sendTSFEContent) { if (isset($this->controller->config['config']['debug'])) { - $debugParseTime = (bool)$this->controller->config['config']['debug']; + $includeParseTime = (bool)$this->controller->config['config']['debug']; } else { - $debugParseTime = !empty($GLOBALS['TYPO3_CONF_VARS']['FE']['debug']); + $includeParseTime = !empty($GLOBALS['TYPO3_CONF_VARS']['FE']['debug']); } - if ($debugParseTime) { - $this->controller->content .= LF . '<!-- Parsetime: ' . $this->timeTracker->getParseTime() . 'ms -->'; + if ($includeParseTime) { + $response = $response->withHeader('X-TYPO3-Parsetime', $this->timeTracker->getParseTime() . 'ms'); } } $this->controller->redirectToExternalUrl(); @@ -257,8 +263,6 @@ class RequestHandler implements RequestHandlerInterface } if ($sendTSFEContent) { - /** @var \TYPO3\CMS\Core\Http\Response $response */ - $response = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\Response::class); $response->getBody()->write($this->controller->content); } GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, ['_FLUSH' => true]);