3.NSURLCredential、NSURLProtectionSpace、NSURLCredentialStorage、NSURLAuthenticatioChallenge 一些访问请求需要证书或者身份凭证进行验证
因此系统提供了一个地方来保存这些凭证,这样我们的挑战对象NSURLAuthenticationChallenge就可以根据特殊的信息(后面说明)来获取这些凭证而不必要每次都需要手动处理,这个保存的地方叫做NSURLCredentialStorage 我们知道一个挑战是服务器端向客户端发起的,所以提供一个凭证是根据服务端要求的信息来建立的,我们的挑战类NSURLAuthenticationChallenge根据服务端要求的挑战方式,从凭证存储类NSURLCredentialStorage
它不单单是一个网络请求类,而是指代Foundation 框架的 URL 系统中的一系列关联的组件: NSURLRequest、NSURLResponse、NSURLProtocol、NSHTTPCookieStorage、NSURLCredentialStorage
+ defaultSessionConfiguration 返回一个标准的 configuration,具有相同的共享 NSHTTPCookieStorage,共享 NSURLCache 和共享NSURLCredentialStorage
configuration(配置) // NSURLSessionConfiguration 有3个工厂方法 // default: 共享 NSHTTPCookieStorage, NSURLCache, NSURLCredentialStorage
Foundation框架中URL加载系统的相互关联的组件:NSURLRequest,NSURLResponse,NSURLProtocol,NSURLCache,NSHTTPCookieStorage,NSURLCredentialStorage credential storage object, or nil to indicate thatno credential storage is to be used */ @property (retain) NSURLCredentialStorage plaincopy /* * The shared session uses the currently set global NSURLCache, * NSHTTPCookieStorage and NSURLCredentialStorage NSObject /* * The sharedsession uses the currently set global NSURLCache, *NSHTTPCookieStorage and NSURLCredentialStorage
*/ @property (nullable, retain) NSURLCredentialStorage *URLCredentialStorage; /* 缓存NSURLRequest的response
defaultSessionConfiguration"返回标准配置,这实际上与NSURLConnection的网络协议栈是一样的,具有相同的共享NSHTTPCookieStorage,共享NSURLCache和共享NSURLCredentialStorage