Skip to content

Commit 6a1ca96

Browse files
authored
Merge pull request #2430 from millenomi/urlauthenticationchallenge
Parity: Networking: URLAuthenticationChallenge
2 parents 38a7b90 + 439533c commit 6a1ca96

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Foundation/URLAuthenticationChallenge.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,24 @@ open class URLAuthenticationChallenge : NSObject, NSSecureCoding {
199199
}
200200
}
201201

202-
extension _HTTPURLProtocol : URLAuthenticationChallengeSender {
203-
202+
class URLSessionAuthenticationChallengeSender : NSObject, URLAuthenticationChallengeSender {
204203
func cancel(_ challenge: URLAuthenticationChallenge) {
205-
NSUnimplemented()
204+
fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.")
206205
}
207206

208207
func continueWithoutCredential(for challenge: URLAuthenticationChallenge) {
209-
NSUnimplemented()
208+
fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.")
210209
}
211210

212211
func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge) {
213-
NSUnimplemented()
212+
fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.")
214213
}
215214

216215
func performDefaultHandling(for challenge: URLAuthenticationChallenge) {
217-
NSUnimplemented()
216+
fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.")
218217
}
219218

220219
func rejectProtectionSpaceAndContinue(with challenge: URLAuthenticationChallenge) {
221-
NSUnimplemented()
220+
fatalError("swift-corelibs-foundation only supports URLSession; for challenges coming from URLSession, please implement the appropriate URLSessionTaskDelegate methods rather than using the sender argument.")
222221
}
223222
}

Foundation/URLSession/URLSessionTask.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ extension _ProtocolClient : URLProtocolClient {
758758

759759
let authenticationChallenge = URLAuthenticationChallenge(protectionSpace: protectionSpace, proposedCredential: proposedCredential,
760760
previousFailureCount: task.previousFailureCount, failureResponse: response, error: nil,
761-
sender: urlProtocol as! _HTTPURLProtocol)
761+
sender: URLSessionAuthenticationChallengeSender())
762762
task.previousFailureCount += 1
763763
self.urlProtocol(urlProtocol, didReceive: authenticationChallenge)
764764
}

0 commit comments

Comments
 (0)