From 439533c792db16438ee0bb5387703b960e6204fa Mon Sep 17 00:00:00 2001 From: Lily Vulcano Date: Wed, 24 Jul 2019 10:46:50 -0700 Subject: [PATCH] Parity: Networking: URLAuthenticationChallenge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class is mostly implemented, but there are several NSUnimplemented() that mark methods that, according to URLSession’s contract, are not meant to be invoked. Replace them with more verbose fatalErrors(). --- Foundation/URLAuthenticationChallenge.swift | 13 ++++++------- Foundation/URLSession/URLSessionTask.swift | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) 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) }