http - content-type wasn send by setting it with header() in php -
i have problem setting content-type php function header(); complete code doesn't ever send output. response-object it. before every output send headers. depending on accept-header set content-type , right output, in easy way looks that:
switch($aceptheader){ case 'text/html': #and othe stupid acept-headers of ie $this->setheader('content-type: text/html; charset=".."'); $this->sendheaders(); $this->senddefault(); break; case 'application/json': $this->setheader('content-type: application/json'); $this->sendjson(); break; case 'application/xml': $this->setheader('content-type: application/xml'); $this->sendxml(); break; }
the method setheader fills array, wicht put foreach-loop header(); function. not important, cause tried in direct way changing $this->setheader()
header('content-type..');
has got same result (later) output ist rendering of array twig template. output. setting of headers not problem. positive result, when print_r(header_list());
. there see header set before. see same response header in every browser, not in every: ie8 shows me html-code string in body after pre-tag. reason, why tested page w3c validator (and other tools). showed same result:
they no content-type header
what mistake? there mistake before set header? - id no wild inlcude stuff or else - setting of header make no trouble - headers change in models between request , response http status, wich followed $response-send();
in every time.
could there manipulation of header while rendering twig-template?
the question is: disturb setting of content-type header header() function?
an interesting thing ist: put following code begining of index.php
header('content-type: text/html'); echo 'test'; exit;
and green test validation tool. header send.
i go throught whole code , loose header, long long way. there has had same problem or imagine have done wrong?
this look-a-like example. switch block not problem, sendheader not, too. cause replaced them in different cases whole afternoon setting header directly - every time same result.
i used these output switch different cases , works fine every time. send json, header $.ajax() of jquery accepts json , not string. produced xml restful api, works fine , sends data in format wanted it. validator tool , ie8 doesn't it. , don't understand why...
switch($aceptheader){ case 'text/html': #and othe stupid acept-headers of ie $this->setheader('content-type: text/html; charset=".."'); $this->sendheaders(); $this->senddefault(); break; case 'application/json': $this->setheader('content-type: application/json'); $this->sendjson(); break; case 'application/xml': $this->setheader('content-type: application/xml'); $this->sendxml(); break; }
forgot breaks in tell code when try next case.
Comments
Post a Comment