views:

267

answers:

1

Just doing a normal HTTP post with a NSMutableURLRequest and sendSynchronousRequest. But the NSHTTPURLResponse object I pass in has a statusCode of zero after the call. I get this error:

Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4d3b3c0 "Operation could not be completed. (NSURLErrorDomain error -1012.)"

but no status code. Why? The status code the server is sending is 401.

+1  A: 

I don't have a solution to the problem, but here is a list of NSURLErrorDomain codes of which -1012 refers to NSURLErrorUserCancelledAuthentication, if that helps narrow down the cause.

Alex Reynolds
Thanks, it seems even though the server sends 401 u cannot check for 401 in your code. You have to check for NSURLErrorUserCancelledAuthentication instead. This seems special to 401. For example 403 works fine.
Andrew Arrow
Just wondering, is this specific only to the sendSynchronousRequest? Because I am able to get 401s with my async connections.
abelito