Executes a proxy autoconfiguration script to determine the best proxy to use to retrieve a specified URL.
SDKs
- iOS 2.0+
- macOS 10.5+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- CFNetwork
Declaration
CFArray Ref CFNetworkCopyProxiesForAutoConfigurationScript(CFString Ref proxyAutoConfigurationScript, CFURLRef targetURL, CFError Ref _Nullable *error);
Parameters
proxyAutoConfigurationScript
A
CFString
containing the code of the autoconfiguration script to execute.targetURL
The URL your application intends to access.
error
The address of an error object reference that is overwritten on return if an error occurs.
Return Value
Returns an array of dictionaries. Each dictionary describes a single proxy. The array is ordered optimally for requesting the URL specified.
Discussion
In general, you should try to download a URL using the first proxy in the array, try the second proxy if the first one fails, and so on.
Every proxy dictionary has an entry for k
. If the type is anything except k
, the dictionary also has entries for the proxy's host and port (under k
and k
respectively). If the type is k
, it has an entry for k
.
The keys for username and password are optional and are present only if the username or password could be extracted from the information passed in (either from the URL itself or from the proxy dictionary supplied). These APIs do not consult any external credential stores such as the Keychain.