Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Orphaned

70840[WIP][FEATURE] Add possibility to add HTTP headers in frontend

Oliver Hader CR -1 V 0 Normal +127 −0 updated 04/21/26, 15:05

Commit message

Using `$GLOBALS['TYPO3_CONF_VARS']['FE']['HTTP']['Response']['Headers']`
is is possible to define additional headers for HTTP responses generated
during frontend rendering.

Per default HTTP headers are only applied in case they are missing and
have not been set by other processes already. This behavior can be
adjusted, with prefixing a header name with `+` (append) or
`!` (override).

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 3
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/40/70840/3 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/40/70840/3 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Oliver Hader -1
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Issues 1

Files 4

Review log 1417

  1. Oliver Hader uploaded patch set 1 08/31/21, 14:15

  2. Mathias Brodala commented on patch set 1 08/31/21, 14:21

    Feature-95054-AddPossibilityToAddHTTPHeadersInFrontend.rst:28

    I like the idea but would suggest a different more concise syntax. Especially "!" looks confusing since it usually denotes negation. Also what do you think about dispatching an event instead? Then listeners could cleanly adjust response headers with additional logic.
  3. core-ci voted on patch set 1 V +1 08/31/21, 14:29 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15939

  4. Helmut Hummel commented on patch set 1 08/31/21, 15:09

    Feature-95054-AddPossibilityToAddHTTPHeadersInFrontend.rst:28 Reply

    I don't think dispatching an event makes sense. one could rather just provide a middleware instead of an event listener
  5. Helmut Hummel commented on patch set 1 08/31/21, 15:13

    Feature-95054-AddPossibilityToAddHTTPHeadersInFrontend.rst:28 Reply

    Regarding the syntax, I would suggest the following way to configure it: Headers => [ 'header-name' => ['value'=> 'header-value', 'add' => true, 'replace' => true] ] which would automatically would make the intention of the configuration clear and we could skip parsing the configuration string
  6. Benni Mack commented on patch set 1 08/31/21, 15:24

    Why not putting this information in Site Config? It is helpful to have different headers for different sites
  7. Oliver Hader commented on patch set 1 CR -1 08/31/21, 15:34

    As briefly discussed with Helmut earlier this day, using a per-site-config makes sense and offers more flexibility.

    Feature-95054-AddPossibilityToAddHTTPHeadersInFrontend.rst:28 Reply Unresolved

    Honestly I HATE arrays...
  8. Oliver Hader updated the commit message in patch set 2 08/31/21, 15:35

  9. Oliver Hader voted on patch set 2 CR -2 08/31/21, 15:35

  10. core-ci voted on patch set 2 V +1 08/31/21, 16:01 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15955

  11. Oliver Hader marked it work in progress 11/18/21, 10:48

  12. Benni Mack wrote 11/29/21, 10:16

    Change destination moved from master to main
  13. Benni Mack updated the commit message in patch set 3 11/29/21, 14:02

  14. core-ci voted on patch set 3 V +1 11/29/21, 15:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20070

  15. Oliver Hader commented on patch set 3 CR -2 09/05/24, 09:34

    Unresolved

    The configuration might be something like this in the end ``` $GLOBALS['TYPO3_CONF_VARS']['FE']['HTTP']['Response']['Headers'] = [ 'dingsbums' => [ 'name' => 'X-Frame-Options', 'value' => 'SAMEORIGIN', 'mode' => HeaderMode::OVERRIDE, ], ]; ```
  16. Oliver Hader voted on patch set 3 CR -1 09/05/24, 09:34

  17. Benni Mack wrote 04/21/26, 15:03

    Removed cc Benni Mack.