Skip to content

Commit fbc2426

Browse files
committed
set http status header for XML/feed responses
1 parent ab8edd1 commit fbc2426

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libraries/src/Error/Renderer/XmlRenderer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
namespace Joomla\CMS\Error\Renderer;
1111

12+
use Joomla\Application\WebApplicationInterface;
1213
use Joomla\CMS\Error\AbstractRenderer;
14+
use Joomla\CMS\Factory;
1315

1416
// phpcs:disable PSR1.Files.SideEffects
1517
\defined('_JEXEC') or die;
@@ -61,6 +63,12 @@ public function render(\Throwable $error): string
6163
// End error element
6264
$xw->endElement();
6365

66+
$app = Factory::getApplication();
67+
68+
if ($app instanceof WebApplicationInterface) {
69+
$app->setHeader('status', $error->getCode() < 400 ? 500 : $error->getCode());
70+
}
71+
6472
// Push the data object into the document
6573
$this->getDocument()->setBuffer($xw->outputMemory(true));
6674

0 commit comments

Comments
 (0)