Fix Atom and RSS content-type headers#4603
Fix Atom and RSS content-type headers#4603Misrilal-Sah wants to merge 1 commit intocachethq:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #4364 by ensuring the Atom and RSS feed endpoints return explicit XML media types (instead of being served as HTML in some environments), improving compatibility with feed readers and validators.
Changes:
- Capture rendered feed output and return it via an explicit Laravel response.
- Set
Content-Typetoapplication/atom+xml; charset=UTF-8for Atom andapplication/rss+xml; charset=UTF-8for RSS.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $content = $this->feed->render($isRss ? 'rss' : 'atom'); | ||
| $contentType = $isRss ? 'application/rss+xml; charset=UTF-8' : 'application/atom+xml; charset=UTF-8'; | ||
|
|
||
| return response($content, 200, ['Content-Type' => $contentType]); |
There was a problem hiding this comment.
Consider keeping the feed library’s ctype configuration and the HTTP response header aligned. The controller sets $this->feed->ctype = 'text/xml' in the constructor, but this method now sends application/atom+xml / application/rss+xml. Updating ctype per format (or removing the now-redundant ctype setting) avoids conflicting sources of truth for Content-Type and makes behavior consistent across environments.
| $content = $this->feed->render($isRss ? 'rss' : 'atom'); | ||
| $contentType = $isRss ? 'application/rss+xml; charset=UTF-8' : 'application/atom+xml; charset=UTF-8'; | ||
|
|
||
| return response($content, 200, ['Content-Type' => $contentType]); |
There was a problem hiding this comment.
Please add/request-level test coverage to lock in the intended Content-Type behavior for /atom and /rss (including the charset parameter). The repo already asserts Content-Type headers in API tests, and without a test this regression could reappear with framework/middleware changes.
Issue link id: #4364
Description:
This fix ensures feed endpoints return explicit XML media types instead of defaulting to HTML in some environments.
Atom now returns application/atom+xml and RSS returns application/rss+xml with UTF-8 charset.
This improves compatibility with feed readers and validation tooling.