Welcome Guest, Not a member yet? Register   Sign In
Error responses change mime type to text/html
#1

The web service we've developed in CodeIgniter has some error conditions where, instead of returning an HTTP status code of 200, we return a code of (for example) 403.  

Our system usually delivers JSON, so we are expecting a response from the server in JSON even when the HTTP code is not 200.

However, even though the mime type is explicitly set to application/json, we are receiving a mime type of text/html in this instance (and all instances where there is an HTTP error code return).

What seems to be happening is that the output is using

Code:
echo($output)

when the status code is 200 and

Code:
exit($output)

when the status code is something else.

Is it possible that using exit in this way will change CodeIgniter's HTTP header information (specifically the mime type)?

The content body is still JSON, as expected.
Reply


Messages In This Thread
Error responses change mime type to text/html - by kootsoop - 12-08-2014, 09:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB