CodeIgniter Forums
How to not send "content-type" - 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: How to not send "content-type" (/showthread.php?tid=60097)



How to not send "content-type" - El Forum - 01-15-2014

[eluser]Ñuño Martínez[/eluser]
I wrote a controller to send the CSS file. In short, it's something like this:
Code:
class styles extends CI_Controller {

  public function _remap ($Metodo)
  {
    $this->load->helper ('file');
    if ($Metodo == 'estilo.css' or $Metodo == 'estilo')
      echo read_file (DIR_TEMPLATE.'estilo.css');
    elseif ($Metodo == 'form.css' or $Metodo == 'form')
      echo read_file (DIR_TEMPLATE.'form.css');
    else
      show_404 ($Metodo);
  }
};
It works. I mean it returns the correct CSS code. The problem is that it includes 'Content-Type: "text/html; charset=..."' in the header so the browser doesn't recognizes it as CSS code, so it doesn't applies the styles to the document. I've tested it in Firefox and Midori (Webkit).

Is it possible to avoid the "Content-Type" header?


How to not send "content-type" - El Forum - 01-15-2014

[eluser]CroNiX[/eluser]
Maybe just set the correct mime type before you send the file out. If there isn't a mime type the browser won't know how to correctly interpret the file.
Code:
header("Content-type: text/css; charset: UTF-8");
echo read_file (DIR_TEMPLATE.'estilo.css');



How to not send "content-type" - El Forum - 01-16-2014

[eluser]Ñuño Martínez[/eluser]
Thank-you very much. I was thinking about using "header" but I discarded it too soon... :red: