Skip to content

Commit

Permalink
[BUGFIX] Sort asset inclusion middleware to execute before content-le…
Browse files Browse the repository at this point in the history
…ngth

Close: #1893
  • Loading branch information
NamelessCoder committed Jan 15, 2024
1 parent 18866ba commit a2444d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
15 changes: 1 addition & 14 deletions Classes/Middleware/AssetInclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Stream;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

class AssetInclusion implements MiddlewareInterface
{
Expand All @@ -37,18 +36,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$stream = fopen('php://temp', 'rw+');
fputs($stream, $contents);

$response = $response->withBody(new Stream($stream));

// Copied from \TYPO3\CMS\Frontend\Middleware\ContentLengthResponseHeader to ensure proper content-length.
if ($GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
if ((!isset($GLOBALS['TSFE']->config['config']['enableContentLengthHeader'])
|| $GLOBALS['TSFE']->config['config']['enableContentLengthHeader'])
&& !$GLOBALS['TSFE']->isBackendUserLoggedIn() && !($GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] ?? false)
&& !($GLOBALS['TSFE']->config['config']['debug'] ?? false) && !$GLOBALS['TSFE']->doWorkspacePreview()
) {
$response = $response->withHeader('Content-Length', (string)$response->getBody()->getSize());
}
}
return $response;
return $response->withBody(new Stream($stream));
}
}
6 changes: 0 additions & 6 deletions Configuration/RequestMiddlewares.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
'fluidtypo3/vhs/asset-inclusion' => [
'target' => \FluidTYPO3\Vhs\Middleware\AssetInclusion::class,
'after' => [
'typo3/cms-frontend/shortcut-and-mountpoint-redirect',
'typo3/cms-frontend/prepare-tsfe-rendering',
'fluidtypo3/vhs/request-availability',
],
'before' => [
'typo3/cms-frontend/content-length-headers',
'typo3/cms-frontend/output-compression',
],
],
'fluidtypo3/vhs/request-availability' => [
Expand Down

0 comments on commit a2444d5

Please sign in to comment.