`fetch_feed()` changes REST API response `Content-Type`
|Reported by:||dlh||Owned by:||rmccue|
|Component:||Feeds||Keywords:||has-patch commit fixed-major|
I have a custom endpoint that returns data derived from widgets. WP_Widget_RSS::widget() calls fetch_feed(), which sends a Content-type: text/html header via SimplePie::handle_content_type(). So, if I don't send another application/json header at the end of my callback, the response content type ends up text/html.
This could be "fixed" by resending the application/json header after running a route callback. But any function could still change the headers later, so resending the header seems a little arbitrary.
Another approach would be to, case-by-case, catch core functions that could inadvertantly change headers during an API response. The attached patch would implement this approach for fetch_feed(). But having to apply the same fix to multiple functions over time could also get inefficient.
Of course, a third approach could be to call it a wontfix based on nothing being "wrong" in either fetch_feed() or the API.
Change History (14)
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.7.1
in reply to:
4 months ago
4 months ago
- Keywords has-patch added; needs-patch removed
- Owner set to rmccue
- Status changed from new to reviewing
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened