currently the server returns the following headers like so:
2014-11-13 00:20:04.079 myiOSApplication 46715:1003]:
{ status code: 200, headers {
Connection = close;
"Content-Length" = 5;
"Content-Type" = "text/html; charset=UTF-8";
"Content-Typesss" = "application/json; charset=UTF-8"; //<-- Notice this appears, but soon as I remove the extra s characters, then it wont override the line above. :( so the content always returns `text/html` instead of the desired `application/json`
Date = "Thu, 13 Nov 2014 00:20:03 GMT";
Server = "Apache/2.2.26 (Amazon)";
Status = "200 OK";
StatusCode = 200;
"X-Powered-By" = "PHP/5.3.28";
} }
I can set other headers with ease, but as SOON as I try to set a header with the key: Content-Type
like so:
header('Content-Type : application/json; charset=UTF-8');
then my key gets overridden with the system one and ignores my header type.
What can I do?
Update 1:
In response to @scuzzy's request for -
What happens if you echo your header then exit(); the script? eg header('Content-Type : application/json; charset=UTF-8');exit('{"hello":"world"}');
Here's the iOS response to that:
2014-11-13 00:59:25.801 myiOSApplication [46849:1f07] RESPONSE: <NSHTTPURLResponse: 0x61800002c060> { URL: http://www.riabp.com/KINGS/Secure/Rajam/Get/Employees } { status code: 200, headers {
Connection = close;
"Content-Length" = 18;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Thu, 13 Nov 2014 00:59:25 GMT";
Server = "Apache/2.2.26 (Amazon)";
"X-Powered-By" = "PHP/5.3.28";
} }
2014-11-13 00:59:25.801 KingsEMS[46849:303] Error: Request failed: unacceptable content-type: text/html
2014-11-13 00:59:25.801 KingsEMS[46849:303] JSON Error: {"hello":"world"}