4

Possible Duplicate:
iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication

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.

Community
  • 1
  • 1
Andrew Arrow
  • 4,248
  • 9
  • 53
  • 80
  • Just to reassure you, it's now 5 years later, and the latest version of XCode still fails miserably with this bug. At least Apple are consistent... http://stackoverflow.com/questions/3912532/ios-how-can-i-receive-http-401-instead-of-1012-nsurlerrorusercancelledauthenti/29341651#29341651 – Mike Gledhill Jun 22 '15 at 12:53

1 Answers1

6

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
  • 95,983
  • 54
  • 240
  • 345
  • 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 Mar 22 '10 at 18:05
  • 3
    Just wondering, is this specific only to the sendSynchronousRequest? Because I am able to get 401s with my async connections. – abelito Jul 06 '10 at 22:53