Project

General

Profile

Actions

Bug #101001

closed

Ease hard type check on custom HTTP headers

Added by Adrian Rudnik over 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Miscellaneous
Target version:
-
Start date:
2023-06-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

Just had to debug why my custom header did not end up in response.

<?php

namespace MyClient\MyExt\Controller;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Http\JsonResponse;

class DemoController extends AbstractController
{
    public function ajaxAction(): ResponseInterface
    {
        return new JsonResponse([], 200, ['X-Page' => 123]);
    }
}

The header will be skipped due to hard checks on the correct type and does not throw any notice in `\TYPO3\CMS\Core\Http\Message::filterHeaders`.

It would be nice to:

- get a notice thrown on invalid headers, easing the developer experience
- allow header values to go through https://www.php.net/manual/de/function.strval.php, therefore allowing any string representation of a given value and the support for classes that implement https://www.php.net/manual/de/class.stringable.php.

Actions

Also available in: Atom PDF