问题描述
使用NSMutableURLRequest和sendSynchronousRequest执行正常的HTTP帖子。但是我传入的NSHTTPURLResponse对象在调用后的statusCode为零。我收到此错误:
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:
错误域= NSURLErrorDomain代码= -1012 UserInfo = 0x4d3b3c0操作无法完成。(NSURLErrorDomain错误-1012。)
Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4d3b3c0 "Operation could not be completed. (NSURLErrorDomain error -1012.)"
但没有状态代码。为什么?服务器发送的状态码是401。
but no status code. Why? The status code the server is sending is 401.
推荐答案
我没有问题的解决方案,但是的列表,其中 -1012
是指,如果这有助于缩小原因。
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.
这篇关于NSHTTPURLResponse statusCode应为401时返回零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!