diff --git a/Foundation/URLAuthenticationChallenge.swift b/Foundation/URLAuthenticationChallenge.swift index db2c2b4d67..5033cb7078 100644 --- a/Foundation/URLAuthenticationChallenge.swift +++ b/Foundation/URLAuthenticationChallenge.swift @@ -199,25 +199,24 @@ open class URLAuthenticationChallenge : NSObject, NSSecureCoding { } } -extension _HTTPURLProtocol : URLAuthenticationChallengeSender { - +class URLSessionAuthenticationChallengeSender : NSObject, URLAuthenticationChallengeSender { func cancel(_ challenge: URLAuthenticationChallenge) { - NSUnimplemented() + fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.") } func continueWithoutCredential(for challenge: URLAuthenticationChallenge) { - NSUnimplemented() + fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.") } func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge) { - NSUnimplemented() + fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.") } func performDefaultHandling(for challenge: URLAuthenticationChallenge) { - NSUnimplemented() + fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.") } func rejectProtectionSpaceAndContinue(with challenge: URLAuthenticationChallenge) { - NSUnimplemented() + fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.") } } diff --git a/Foundation/URLSession/URLSessionTask.swift b/Foundation/URLSession/URLSessionTask.swift index 488ac2da98..6b22203642 100644 --- a/Foundation/URLSession/URLSessionTask.swift +++ b/Foundation/URLSession/URLSessionTask.swift @@ -758,7 +758,7 @@ extension _ProtocolClient : URLProtocolClient { let authenticationChallenge = URLAuthenticationChallenge(protectionSpace: protectionSpace, proposedCredential: proposedCredential, previousFailureCount: task.previousFailureCount, failureResponse: response, error: nil, - sender: urlProtocol as! _HTTPURLProtocol) + sender: URLSessionAuthenticationChallengeSender()) task.previousFailureCount += 1 self.urlProtocol(urlProtocol, didReceive: authenticationChallenge) }