1
我已經設置了一個簡單的NSURLConnection來查詢一個http服務器。NSURLConnection委託沒有得到它的didReceiveAuthenticationChallenge方法在服務器狀態401
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:方法,但事實並非如此。
我也實現
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection {
return FALSE;
}
只是爲了確保它不會試圖沿緩存憑據從我的鑰匙串,它不發送。