Skip to content

Commit 4b6d7f6

Browse files
authored
Merge pull request #2860 from millenomi/sr-12676-basic-auth-delegate
Fix authentication through the session task delegate (SR-12676)
2 parents 1c561c0 + 4360a00 commit 4b6d7f6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Sources/FoundationNetworking/URLResponse.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ open class HTTPURLResponse : URLResponse {
197197
if key.isEmpty { continue }
198198
if key.hasPrefix("x-") || key.hasPrefix("X-") {
199199
canonicalizedFields[key] = value
200+
} else if key.caseInsensitiveCompare("WWW-Authenticate") == .orderedSame {
201+
canonicalizedFields["WWW-Authenticate"] = value
200202
} else {
201203
canonicalizedFields[key.capitalized] = value
202204
}

Sources/FoundationNetworking/URLSession/URLSessionTask.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,7 @@ extension _ProtocolClient : URLProtocolClient {
950950
}
951951
}
952952

953-
switch session.behaviour(for: task) {
954-
case .taskDelegate(let delegate):
953+
if let delegate = session.delegate as? URLSessionTaskDelegate {
955954
session.delegateQueue.addOperation {
956955
delegate.urlSession(session, task: task, didReceive: challenge) { disposition, credential in
957956

@@ -971,7 +970,7 @@ extension _ProtocolClient : URLProtocolClient {
971970

972971
}
973972
}
974-
default:
973+
} else {
975974
attemptProceedingWithDefaultCredential()
976975
}
977976
}

0 commit comments

Comments
 (0)