Objective-C NSURLConnection with RESTful web service, error handling
I´m connection to a RESTful web service, using JSON to retrive data. The problem i have is that the server gives a 200 OK response even if the username and password is wrong. It then responds with a html page with instructions. I wa开发者_如何学Pythonnt to do some error handling when a user is logging in, is there a way in Objective-C to check the content-type of the response and compare that to "application/json"?
Thanks in advance!
The NSURLResponse
class has a MIMEType
property which I think can be used.
Or, for HTTP, there is the allHeaderFields
on NSHTTPURLResponse
which returns a dictionary of the response headers (then you just check the Content-Type
header).
精彩评论