Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa NSURLConnection委托不';无法在服务器状态401上获取其didReceiveAuthenticationChallenge方法_Cocoa_Macos_Nsurlconnection_Core Foundation - Fatal编程技术网

Cocoa NSURLConnection委托不';无法在服务器状态401上获取其didReceiveAuthenticationChallenge方法

Cocoa NSURLConnection委托不';无法在服务器状态401上获取其didReceiveAuthenticationChallenge方法,cocoa,macos,nsurlconnection,core-foundation,Cocoa,Macos,Nsurlconnection,Core Foundation,我已经设置了一个简单的NSURLConnection来查询http服务器 GET /path HTTP/1.1 Host: 192.168.1.161:8282 User-Agent: NetTest1.0 CFNetwork/441.0.2 Darwin/9.6.0 Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate Pragma: no-cache Connection: keep-alive 服务器以代码40

我已经设置了一个简单的NSURLConnection来查询http服务器

GET /path HTTP/1.1
Host: 192.168.1.161:8282
User-Agent: NetTest1.0 CFNetwork/441.0.2 Darwin/9.6.0
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Pragma: no-cache
Connection: keep-alive
服务器以代码401和WWW认证头集进行响应

HTTP/1.1 401
Connection: close
Pragma: no-cache
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-control: no-cache
Cache-last-checked: Thu, 01 Dec 1994 16:00:00 GMT
Last-modified: Tue, 07 Apr 02009 22:55:48 CEST
Content-type: text/html; charset=iso-8859-1
WWW-Authenticate: Basic realm:
我想这会向我的代理的连接发送一条消息:didReceiveAuthenticationChallenge:method,但它不会

我还实现了

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection {
  return FALSE;
}

只是为了确保它不会尝试从我的密钥链发送缓存凭据,它不会。WWW-Authenticate标头的格式不正确,请尝试:

WWW-Authenticate: Basic realm="My Realm"

WWW身份验证标头的格式不正确,请尝试:

WWW-Authenticate: Basic realm="My Realm"