NSHTTPURLResponse statusCode应为401时返回零 [英] NSHTTPURLResponse statusCode is returning zero when it should be 401

查看:294
本文介绍了NSHTTPURLResponse statusCode应为401时返回零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

iOS:我怎样才能收到HTTP 401而不是-1012 NSURLErrorUserCancelledAuthentication

使用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.

推荐答案

我没有问题的解决方案,但是这里是 NSURLErrorDomain 代码的列表,其中 -1012 是指 NSURLErrorUserCancelledAuthentication ,如果这有助于缩小原因。

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时返回零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆