83940[BUGFIX] Handle the output of headers in extbase according to PSR-7
Commit message
Review
-
Code review CR +1
- Fabien Udriot +1
-
Verified V 0
- core-ci +1 CI
Issues 1
Files 1
Review log 2329
Show 24 earlier messages
-
David Hedden uploaded patch set 1 04/19/24, 16:53
-
David Hedden updated the commit message in patch set 2 04/19/24, 16:57
-
core-ci voted on patch set 1 V +1 04/19/24, 17:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56348
-
core-ci voted on patch set 2 V +1 04/19/24, 17:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56349
-
David Hedden updated the commit message in patch set 3
V +104/19/24, 17:15 -
core-ci voted on patch set 3 V +1 04/19/24, 17:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56350
-
Garvin Hicking commented on patch set 3 04/19/24, 21:31
Could you maybe provide a case when/how this affects logic/workflow, either here or in the ticket? So that it can easier be tested and verified, would help me and maybe others to see the flaw in current logic. Also I'm wondering if we'd need a functional test for this, and this would help that effort. :-) -
David Hedden commented on patch set 3 04/20/24, 00:10
Reply
For example, if someone wants to set multiple cookies. ``` # header(string $header, bool $replace = true); header('Set-Cookie: value1=foo'); header('Set-Cookie: value2=foo', false); # With response interface: $response->withAdditionalHeader('Set-Cookie', ['value1=foo', 'value2=bar']); ``` The Problem with how extbase handles this case is that it calls header without the false, to prevent replacing the same header. So only the second cookie with bar will be set. The logic to replace a header is already handled via the response interface with the function $response->withHeader(). -
Garvin Hicking commented on patch set 3 04/20/24, 07:15
Reply
Thanks for more info on this. Do you know if there might be extbase code that relies on overwriting headers as it is currently, like setting Content-Type or CSP directive changes, Accept-Headers or something like that? I think adding/having a test case that woild swtup a few cases could help, also for possibld future regressions? -
Stefan Bürk commented on patch set 3 04/20/24, 18:19
Reply
Setting/Dealing with headers with the "broken" response chain through the content object render stack (due to early adding that to extbase) is not nice generally, also sending the `headers()`. Albeit accpeting the statement from the commit message and the use-case, I guess we need to think here deeper. What if two extbase plugins dealing with same header (not the cookie one) ? Currently, last one would win - with this change it would be duplicated - can there be a use-case where duplicationg it now would be bad ? Thinking about things like content-type, content-disposition or other stuff. Need to thing more about that. However, testing `header()` usages is not really possible in functional tests, and adding it as acceptance tests is quite complicated - so I would not force/try to add it here (if change can be finally accepted). -
David Hedden commented on patch set 3 04/21/24, 08:13
Reply
About multiple headers of the same kind, from the RFC-9110, only Set-Cookie is the exception that is allowed multiple times. All others are supposed to be joined via a comma. PSR-7 avoids this issue by stating that the standard is extensible and should be handled by the framework / user. https://www.rfc-editor.org/rfc/rfc9110.html https://mwop.net/blog/2015-07-28-on-psr7-headers.html The question could be if TYPO3 should safeguard the user from setting the wrong headers, by automatically joining multiple headers except Set-Cookie. Regarding this fix, headers for extbase are only set if `headers_sent() === false`, so the first plugin that sends headers wins. So this change would only affect users that are using the response interface wrong inside one plugin call. -
Benni Mack updated the commit message in patch set 4
V +110/18/24, 13:28 -
core-ci voted on patch set 4 V -1 10/18/24, 21:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67970
-
Benni Mack rebased onto patch set 5
V -110/28/24, 11:38 -
core-ci voted on patch set 5 V +1 10/28/24, 11:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68724
-
Benni Mack commented on patch set 5 10/29/24, 18:27
Reply
Please have a look at AbstractApplication which deals with SetCookie properly. Maybe we need this code within Extbase as well? -
David Hedden uploaded patch set 6
V +110/31/24, 13:42 -
core-ci voted on patch set 6 V +1 10/31/24, 13:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68925
-
David Hedden commented on patch set 6 11/14/24, 09:56
Reply
Done -
Fabien Udriot voted on patch set 6 CR +1 11/14/24, 10:59
-
Benni Mack commented on patch set 6 01/28/25, 11:35
Bootstrap.php:182Ideally, we can attach status codes to the "main" response that is sent down the middlewares. -
Christian Kuhn commented on patch set 6 01/28/25, 12:36
Bootstrap.php:182Replywe have no repsonse in extbase bootstrap, it has not yet been created. allowing this will require a not too small change in COR. i kinda agree to your comment, but have no idea how to achieve it. do you have an idea? -
Benni Mack commented on patch set 6 03/04/25, 07:16
Bootstrap.php:182ReplyIn the past, we've "parked" this within TSFE :) So, we'd need to park this in a state-based object. I previously had something like this in mind which I called "ResponseData", which is also the chunk that should be put in the cache (instead of this large string with placeholders). -
Benjamin Franzke commented on patch set 6 03/04/25, 12:22
Bootstrap.php:182ReplyAck in general ResponseInterface has no state besides headers. The response state that is to be "parked" is to be parked in mutable attributes of the respective request. That's what we do for example in the `frontend.cache.collector` request attribute for cache tags that are associated with the response. For this case that means we can park the emitted extbase headers in a request attribute that collects the headers and applies them in a middleware, which would ensure that headers from multiple plugins are merged – without the need for knowing the response object yet. -
Benni Mack commented on patch set 6 03/23/25, 09:20
Bootstrap.php:182ReplyI have more topic regarding this... What if we have two extbase actions, the one returning a 301 and the second a 404 status code - which should be the one that is "correct"? -
David Hedden commented on patch set 6 03/23/25, 10:06
Bootstrap.php:182ReplyTo add one more, Content-Type has the same problem. I think there is not really a correct answer. So I'm in favor of going with the current approach, that the first plugin wins. So current sites that rely on this behavior won't break. At least if all responses are collected in one place, a warning could be thrown if such things happen. -
Garvin Hicking commented on patch set 6 03/23/25, 10:07
Bootstrap.php:182Reply Unresolved$0.02: I would argue that if an extbase action that modifies the whole page response status, it must propagate this and end processing, and the developer needs to decide which action does it. If not, IMO the last action setting response status needs to "win", because without stopping execution earlier actions would state "well, override me if you want". -
Christian Kuhn commented on patch set 6 11/23/25, 02:11
this has been changed with https://review.typo3.org/c/Packages/TYPO3.CMS/+/90471 i hope it is ok to abandon here. -
Christian Kuhn abandoned the change 11/23/25, 02:11