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.
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.
来源:https://stackoverflow.com/questions/2188099/nshttpurlresponse-statuscode-is-returning-zero-when-it-should-be-401