viewing the output buffer - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: viewing the output buffer (/showthread.php?tid=72028) |
viewing the output buffer - richb201 - 10-26-2018 this code is shoving my payload (aka $table) into the header: $this->output ->set_content_type('application/json') ->set_header("Access-Control-Allow-Origin", "*") ->set_output(json_encode($table)); } Here is the Apache error log. [Fri Oct 26 18:22:07.162178 2018] [proxy_fcgi:error] [pid 2001:tid 139930806171392] [client 69.124.178.164:57141] malformed header from script 'index.php': Bad header: {"0":["{choose}","IOS","Mac"," [Fri Oct 26 18:22:07.163669 2018] [proxy_fcgi:error] [pid 2001:tid 139930806171392] [client 69.124.178.164:57141] AH01070: Error parsing script headers [Fri Oct 26 18:22:07.163679 2018] [proxy_fcgi:error] [pid 2001:tid 139930806171392] (22)Invalid argument: [client 69.124.178.164:57141] AH01075: Error dispatching request to : [Fri Oct 26 18:22:33.796554 2018] [proxy_fcgi:error] [pid 2001:tid 139930797778688] [client 69.124.178.164:57179] malformed header from script 'index.php': Bad header: {"0":["{choose}","IOS","Mac"," [Fri Oct 26 18:22:33.796627 2018] [proxy_fcgi:error] [pid 2001:tid 139930797778688] [client 69.124.178.164:57179] AH01070: Error parsing script headers [Fri Oct 26 18:22:33.796633 2018] [proxy_fcgi:error] [pid 2001:tid 139930797778688] (22)Invalid argument: [client 69.124.178.164:57179] AH01075: Error dispatching request to : Is there any way to view the header+output prior to it being put on the network wire? The header seems correct, its just in the wrong place. RE: viewing the output buffer - richb201 - 10-27-2018 OK. After over a month of trial and error and banging my head against the wall i figured it out (or a workaround). I now use: header('Content-type: application/json'); header("Access-Control-Allow-Origin: *"); echo ($json); instead of $this->output ->set_content_type('application/json') ->set_header("Access-Control-Allow-Origin", "*") ->set_output(json_encode($table)); RE: viewing the output buffer - jreklund - 10-27-2018 Do you have an exit; or die; after $this->output? If that's the case you need to add _display() after. If that causes the malformed headers to be rendered. https://www.codeigniter.com/userguide3/libraries/output.html#CI_Output::_display |