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

WordPress Trac noreply at wordpress.org
Wed Jan 4 18:37:08 UTC 2017


#39066: `fetch_feed()` changes REST API response `Content-Type`
--------------------------+-----------------------
 Reporter:  dlh           |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.7.1
Component:  Feeds         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  rest-api
--------------------------+-----------------------

Comment (by stevenkword):

 Replying to [comment:4 rmccue]:
 > I would rather we simply not call `handle_content_type()`. This only
 exists to set the charset in the header to match the feed, but we already
 set the charset to `get_option( 'blog_charset' )` above, so it's not
 necessary. At best, it's redundant already.

 I can confirm this resolves the header "Content-type:" issue and have
 attached [attachment:39066.3.diff]

 I used to code below to verify functionality.  However, I am questioning
 if it is okay to force the character set from a 3rd party to the same one
 used by the WP instance.

 {{{
 <?php
 /**
  * Grab custom feed via JSON
  *
  * @param array $data Options for the function.
  * @return string URI of the feed.
  */
 function my_custom_rest_endpoint( $data ) {

         $uri = 'https://make.wordpress.org/core/feed/';
         $feed = fetch_feed( $uri );

         return $uri;
 }

 // e.g.) http://src.wordpress-develop.dev/wp-json/custom/v1/feed
 add_action( 'rest_api_init', function () {
         register_rest_route( 'custom/v1', '/feed/', array(
                 'methods' => 'GET',
                 'callback' => 'my_custom_rest_endpoint',
         ) );
 } );
 }}}

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


More information about the wp-trac mailing list