TIL: How do you add a header to a separate Response in a Controller->Action in Neos Flow?

I needed to send a number of Cache-* and Content-* header while working on a project where download was done in my own DowloadController.

I’m using PHP Framework Neos Flow for this project.

Since Neos Flow 6, the PSR-7 has been implemented and I can no longer set it directly on the $this->response object.

Instead, headers are added to a Component being executed in the rendering. So, adding a header with a value is done like this

$this->response->setComponentParameter(SetHeaderComponent::class, 'Cache-control', 'private');

Inside your action – adding several is one per line

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *