Support » Plugin: JSON API » [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;

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