Silversnail
Silversnail

Reputation: 386

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 want 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!

Upvotes: 1

Views: 591

Answers (1)

vicvicvic
vicvicvic

Reputation: 6244

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).

Upvotes: 1

Related Questions