[wp-trac] [WordPress Trac] #39066: `fetch_feed()` changes REST API response `Content-Type`

WordPress Trac noreply at wordpress.org
Sun Dec 4 19:10:52 UTC 2016


#39066: `fetch_feed()` changes REST API response `Content-Type`
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39066>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list