问题
I've got system proxy configuration which include user credentials (name+password), and I'd like to use it with my NSURLSession
object to send http messages in macOS or iOS applications.
From connectionProxyDictionary
documentation, I haven't set this value to get what I need :
The default value is NULL, which means that tasks use the default system settings`
My http message goes through the server. However, it appears that the packet doesn't have Proxy-Authorization
and I get Cache Access Denied
from the proxy, although in system configuration the credentials are well set.
So I need to explicitly set the Proxy-Authorization header according to the global proxy configuration SCDynamicStoreCopyProxies
. Perhaps there's a way to avoid it and let the NSURLSession take the credentials automatically. ?
I've found out that I should provide those credentials after getting proper challenge. However, this challenge never occur (my callback doesn't get called).
来源:https://stackoverflow.com/questions/61663111/using-system-proxy-in-nsurlsession-unable-to-get-challenge-for-setting-credent