Using system proxy in NSURLSession - unable to get challenge for setting credentials

泪湿孤枕 提交于 2021-02-07 04:28:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!