From a158b25e77977a661ba7ca3bcec08986e288c5d5 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:34:15 +0200 Subject: [PATCH] TASK: Simplify module controller request handling and incorporate fix https://github.com/neos/neos-development-collection/pull/5179 for Neos 9 --- .../Classes/Controller/Backend/ModuleController.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Neos.Neos/Classes/Controller/Backend/ModuleController.php b/Neos.Neos/Classes/Controller/Backend/ModuleController.php index 6958ac3aa78..26e258d2bcd 100644 --- a/Neos.Neos/Classes/Controller/Backend/ModuleController.php +++ b/Neos.Neos/Classes/Controller/Backend/ModuleController.php @@ -112,16 +112,15 @@ public function indexAction(array $module) if ($moduleResponse->hasHeader('Location')) { // Preserve redirects see b57d72aeeaa2e6da4d9c0a80363025fefd63d813 - // todo just return $moduleResponse and not merge with $this->response? - $this->redirectToUri($moduleResponse->getHeaderLine('Location'), 0, $moduleResponse->getStatusCode()); + return $moduleResponse; } elseif ($moduleRequest->getFormat() !== 'html') { // Allow ajax request with json or similar dd7e5c99924bf1b8618775bec08cc4f2cb1a6d2a - // todo just return $moduleResponse and not merge with $this->response? + // todo just return $moduleResponse and trust its content-type instead of inferring the requested content-type $mediaType = MediaTypes::getMediaTypeFromFilename('file.' . $moduleRequest->getFormat()); if ($mediaType !== 'application/octet-stream') { - $this->response->setContentType($mediaType); + $moduleResponse = $moduleResponse->withHeader('Content-Type', $mediaType); } - return $moduleResponse->getBody(); + return $moduleResponse; } else { /** @var ?Account $authenticatedAccount */ $authenticatedAccount = $this->securityContext->getAccount();