Ios NSURLConnection不';t在HTTP 401之后调用NSURLConnectionLegate身份验证方法
我正在使用一个web服务,该服务使用HTTP基本身份验证和Ios NSURLConnection不';t在HTTP 401之后调用NSURLConnectionLegate身份验证方法,ios,nsurlconnection,http-authentication,nsurlconnectiondelegate,nsurlcredential,Ios,Nsurlconnection,Http Authentication,Nsurlconnectiondelegate,Nsurlcredential,我正在使用一个web服务,该服务使用HTTP基本身份验证和NSURLConnection。在我的nsurconnectionelegate中,我实现了–[nsurconnectionelegate连接:canAuthenticateAgainstProtectionSpace:, –[NSURLConnectionLegate连接:didCancelAuthenticationChallenge:][/code>,以及 –[NSURLConnectionLegate连接:didReceiveAu
NSURLConnection
。在我的nsurconnectionelegate
中,我实现了–[nsurconnectionelegate连接:canAuthenticateAgainstProtectionSpace:
,
–[NSURLConnectionLegate连接:didCancelAuthenticationChallenge:][/code>,以及
–[NSURLConnectionLegate连接:didReceiveAuthenticationChallenge:][/code>,但它们都没有被调用
我已尝试实现–[nsurconnectionelegate connectionShouldUseCredentialStorage:
以返回是
和否
,但没有效果
最后,不是实现–[nsurlconnectionelegate连接:canAuthenticateAgainstProtectionSpace:
,
–[NSURLConnectionLegate连接:didCancelAuthenticationChallenge:][/code>,以及
–[NSURLConnectionLegate连接:didReceiveAuthenticationChallenge://code>,我实现了–[NSURLConnectionLegate连接:willSendRequestForAuthenticationChallenge://code>,但也没有调用它
如何使NSURLConnection
调用nsurlconnectionelegate
的身份验证回调?我的HTTP服务器没有返回WWW-Authenticate
头
我的服务器的响应:
HTTP/1.1 401 Unauthorized
Date: Wed, 19 Jun 2013 14:43:30 GMT
Server: Apache-Coyote/1.1
Expires: Wed, 19 Jun 2013 14:43:30 GMT
Vary: Accept-Encoding,User-Agent
Cache-Control: no-store, no-cache, must-revalidate, private, max-age=0
Content-Length: 0
Content-Type: text/plain
另一个带有WWW-Authenticate
头的服务器响应:
HTTP/1.1 401 Authorization Required
Date: Wed, 19 Jun 2013 14:44:47 GMT
Server: Apache/2.2.17 (CentOS)
WWW-Authenticate: Basic realm="[LDAP/PROD] Active Directory"
Content-Length: 0
Connection: close
Content-Type: text/plain
看起来NSURLConnection
需要在其响应中使用WWW-Authenticate
头才能调用nsurlconnectionelegate
的身份验证回调
我已经考虑过了。请复制一下
显然,我必须手动设置授权
标题