Title: [Plugin: JSON API] Content-Length header?
Last modified: August 19, 2016

---

# [Plugin: JSON API] Content-Length header?

 *  [lambeco](https://wordpress.org/support/users/lambeco/)
 * (@lambeco)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-json-api-content-length-header/)
 * I’ve been loading posts into Flash using this JSON API plugin, and I kept getting
   a weird problem where the response would sometimes list the size of the file 
   as 0 bytes.
 * Adding `header("Content-Length: " . strlen($result),true);` to the output function
   in response.php seems to have alleviated the issue. Unless there’s a problem 
   with this that I haven’t foreseen, it would be useful to have in the official
   release of the plugin.
 *     ```
       function output($result) {
       	$charset = get_option('blog_charset');
       	if (!headers_sent()) {
       		header("Content-Type: application/json; charset=$charset", true);
       		header("Content-Disposition: attachment; filename=\"json_api.json\"", true);
       		header("Content-Length: " . strlen($result),true);
       	}
       	echo $result;
       }
       ```
   
 * [http://wordpress.org/extend/plugins/json-api/](http://wordpress.org/extend/plugins/json-api/)

The topic ‘[Plugin: JSON API] Content-Length header?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [lambeco](https://wordpress.org/support/users/lambeco/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/plugin-json-api-content-length-header/)
 * Status: not resolved