Thanks Quinn, it was coming out of the cache, and adding your suggested cachePolicy fixes the issue.
Incidentally, when I set up a delegate to handle an authentication challenge like this:
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
print("didReceive challenge \(challenge.protectionSpace.authenticationMethod), failure count: \(challenge.previousFailureCount)") completionHandler(.useCredential, nil)
}
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
print("Task: \(task.taskIdentifier) didReceive challenge \(challenge.protectionSpace.authenticationMethod)") completionHandler(.useCredential, nil)
}
The output is:
didReceive challenge NSURLAuthenticationMethodServerTrust, failure count: 0
didReceive challenge NSURLAuthenticationMethodServerTrust, failure count: 0
I'm not sure why I am not getting a NSURLAuthenticationMethodHTTPBasic challenge?
Bill Aylward
Topic:
App & System Services
SubTopic:
General
Tags: