我设置了一个简单的 NSURLConnection 来查询 http-server。
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-Authenticate 标头集
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: 方法,但事实并非如此。
我也实施了
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection {
return FALSE;
}
只是为了确保它不会尝试从我的钥匙串中发送缓存的凭据,而事实并非如此。