WordPress.org

Ready to get started?Download WordPress

Forums

JSON API
Content-Length header? (1 post)

  1. lambeco
    Member
    Posted 3 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags