You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our image asset backend is protected by HTTP Digest Auth. We followed the instructions here and did implement and set our AuthenticationChallengeResponsable to handle authentication, but that didn't work. It was called and all, but HTTP Digest wasn't handled correctly.
I digged deeper into Apple documentation to understand what was happening and realised that HTTP Digest Auth was not handled in URLSessionDelegate.urlSession(_ session:, didReceive, completionHandler:) but in URLSessionTaskDelegate.urlSession(_ session:, task:, didReceive:, completionHandler:).
Our (temporary) solution was to add the correct callback to ImageDownloaderSessionHandler:
class ImageDownloaderSessionHandler {
...
/**
This method is exposed since the compiler requests. Do not call it.
*/
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let downloader = downloadHolder else {
return
}
downloader.authenticationChallengeResponder?.downloader(downloader, didReceive: challenge, completionHandler: completionHandler)
}
/// This will handle HTTP Basic/Digest authentication challenges
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let downloader = downloadHolder else {
return
}
downloader.authenticationChallengeResponder?.downloader(downloader, didReceive: challenge, completionHandler: completionHandler)
}
...
}
Do you feel that this is the correct fix? If yes, we can provide a pull request.
The text was updated successfully, but these errors were encountered:
Hi, yes. I believe it should be a correct way to fix it and I am glad to receive a pull request on this. Thank you!
And instead of reusing the current AuthenticationChallengeResponsable's downloader(_:didReceive :completionHandler:), I prefer to add a new protocol method with task contained as its parameter, to make it a forward of the original method.
Hi there,
Our image asset backend is protected by HTTP Digest Auth. We followed the instructions here and did implement and set our
AuthenticationChallengeResponsable
to handle authentication, but that didn't work. It was called and all, but HTTP Digest wasn't handled correctly.I digged deeper into Apple documentation to understand what was happening and realised that HTTP Digest Auth was not handled in
URLSessionDelegate.urlSession(_ session:, didReceive, completionHandler:)
but inURLSessionTaskDelegate.urlSession(_ session:, task:, didReceive:, completionHandler:)
.Our (temporary) solution was to add the correct callback to
ImageDownloaderSessionHandler
:Do you feel that this is the correct fix? If yes, we can provide a pull request.
The text was updated successfully, but these errors were encountered: