Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extbase: Example with response in different content type does not work #2525

Open
brotkrueml opened this issue Dec 3, 2022 · 2 comments
Open
Labels

Comments

@brotkrueml
Copy link
Contributor

The example on page:

https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Reference/View/Index.html#response-in-a-different-format

says, it is enough to return a response with a defined content-type header (text/xml). But this is wrong. In page renderer it is overwritten with text/html. As this comes from EXT:blog_example, this is not as easy to adjust. Perhaps it is correctly set in the blog example as in TypoScript the header is set additionally. But this is only the case because the example is defined with a page type.

The solution is to throw a PropagateResponseException($response, 200);. This is also the way to go with downloads, like:

$response = $this->responseFactory->createResponse()
    ->withHeader('Cache-Control', 'private')
    ->withHeader('Content-Disposition', sprintf('attachment; filename="%s"', $filename))
    ->withHeader('Content-Length', (string)filesize($filePath))
    ->withHeader('Content-Type', 'application/pdf')
    ->withBody($this->streamFactory->createStreamFromFile($filePath));

throw new PropagateResponseException($response, 200); 
@brotkrueml brotkrueml added the bug label Dec 3, 2022
@brotkrueml brotkrueml changed the title Extbase: Example with response in different format does not work Extbase: Example with response in different content type does not work Dec 3, 2022
@DavidBruchmann
Copy link
Contributor

@brotkrueml is this related to v11? If so, is it the same in v12?

@brotkrueml
Copy link
Contributor Author

Yup, v11 and v12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants