Without checking the Content-Type of the HTTP response, exceptions can be thrown when trying to JSON.parse() non-JSON data, for example this response: Unknown URL. See Twitter Streaming API documentation at http://dev.twitter.com/pages/streaming_api.
So either/both Content-Type needs to be checked or/and JSON.parse() should have a try-catch around it and errors handled appropriately.
Without checking the
Content-Type
of the HTTP response, exceptions can be thrown when trying toJSON.parse()
non-JSON data, for example this response:Unknown URL. See Twitter Streaming API documentation at http://dev.twitter.com/pages/streaming_api
.So either/both
Content-Type
needs to be checked or/andJSON.parse()
should have a try-catch around it and errors handled appropriately.