![]() |
Header Response 200 and Content Type text/plain via Controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Header Response 200 and Content Type text/plain via Controller (/showthread.php?tid=23826) |
Header Response 200 and Content Type text/plain via Controller - El Forum - 10-22-2009 [eluser]shiftpoint[/eluser] So I have been banging my head off the wall with this problem. Hoping you guys can help. Here is the situation. I have index.php setup as the default php page. I have a controller called "processsmsdata". Within this control I do some processing via a few funcations and models. at the end of the main function i do the following: Code: $data = "Successfully signed up"; for some reason the content type is still set to text/html. Now I know the header works because if i create a test.php file with the following outside of the codeigniter directories it works perfect: Code: $data = "Successfully signed up"; I'm thinking it has something to do with the output class however I can't seem to get it to work. I have tried loading a view with the second piece of code to no avail. Can you guys help???? Header Response 200 and Content Type text/plain via Controller - El Forum - 10-22-2009 [eluser]shiftpoint[/eluser] There is nothing in the output library where you can set the content type. Is it defaulted at some other point? Header Response 200 and Content Type text/plain via Controller - El Forum - 10-22-2009 [eluser]pistolPete[/eluser] Do you use a .htaccess file (or similar) to force a specific header? Header Response 200 and Content Type text/plain via Controller - El Forum - 10-22-2009 [eluser]shiftpoint[/eluser] [quote author="pistolPete" date="1256263495"]Do you use a .htaccess file (or similar) to force a specific header?[/quote] nope. Again if i put just a standard php page in the root directory with setting the header via the php header() function works perfect. For some reason the content type is getting set before I manually set it... i think... Header Response 200 and Content Type text/plain via Controller - El Forum - 10-22-2009 [eluser]tomcode[/eluser] Try with : Code: $this->output->set_output($data); instead the echo statement. Header Response 200 and Content Type text/plain via Controller - El Forum - 10-23-2009 [eluser]shiftpoint[/eluser] [quote author="tomcode" date="1256271796"]Try with : Code: $this->output->set_output($data); instead the echo statement.[/quote] Nope. I'm telling you something is setting the header before it even gets to that part of the code. I just can't figure out what/where.... Header Response 200 and Content Type text/plain via Controller - El Forum - 10-23-2009 [eluser]tomcode[/eluser] Have You actually tried it ? Because I had the same problem where the with the output class defined headers would only be send when I used set_output. When I echoed the data the headers would not be set. Header Response 200 and Content Type text/plain via Controller - El Forum - 10-23-2009 [eluser]shiftpoint[/eluser] [quote author="tomcode" date="1256340775"]Have You actually tried it ? Because I had the same problem where the with the output class defined headers would only be send when I used set_output. When I echoed the data the headers would not be set.[/quote] Yeah i tried it just now. The problem is something is setting the content type of the page to "text/html" before I set it to "text/plain" ... Header Response 200 and Content Type text/plain via Controller - El Forum - 10-23-2009 [eluser]BrianDHall[/eluser] Hm, have you tried using a Firefox plugin to see all the headers being sent and received? I use Live HTTP Headers. Check and see just exactly what headers are being sent even after you are modifying the headers. One thing I see right away though is you might try this: Code: $data = "Successfully signed up"; Note the last line - the headers class member is defined in Output.php to keep track of what headers are stored for sending. This and checking what headers are Really being sent and received should give you a much better idea of what is going on. Note also I removed all the \r\n usage. I don't know for sure if this is right or wrong, but in the manual when calling set_header() they did nothing special as far as that sort of things go. Header Response 200 and Content Type text/plain via Controller - El Forum - 10-23-2009 [eluser]shiftpoint[/eluser] array(3) { [0]=> array(2) { [0]=> string(35) "Date: Fri, 23 Oct 09 18:53:43 +0000" [1]=> bool(true) } [1]=> array(2) { [0]=> string(38) "Content-Type: text/plain charset=UTF-8" [1]=> bool(true) } [2]=> array(2) { [0]=> string(18) "Content-Length: 22" [1]=> bool(true) } } thats what the var_dump outputs....still no go... |