iOS Developer Library

Developer

CFProxySupport Reference

Options
Deployment Target:

On This Page
Language:

CFProxySupport Reference

The CFProxySupport API enables you to take advantage of global proxy configuration settings in your application.

The CFProxySupport functions return arrays of dictionaries, where each dictionary describes a single proxy. The arrays represent the order in which the proxies should be tried. 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 kCFProxyTypeKey. If the type is anything except kCFProxyTypeAutoConfigurationURL, the dictionary also has entries for the proxy's host and port (under kCFProxyHostNameKey and kCFProxyPortNumberKey respectively). If the type is kCFProxyTypeAutoConfigurationURL, it has an entry for kCFProxyAutoConfigurationURLKey.

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.

Functions

Callbacks

  • Callback function called when a proxy autoconfiguration computation has completed.

    Declaration

    Swift

    typealias CFProxyAutoConfigurationResultCallback = (UnsafeMutablePointer<Void>, CFArray, CFError?) -> Void

    Objective-C

    typedef CALLBACK_API_C( void, CFProxyAutoConfigurationResultCallback )( void *client, CFArrayRef proxyList, CFErrorRef error );

    Parameters

    client

    The client reference originally passed in the clientContext parameter of the CFNetworkExecuteProxyAutoConfigurationScript or CFNetworkExecuteProxyAutoConfigurationURL call that triggered this callback.

    proxyList

    The list of proxies returned by the autoconfiguration script. This list is in a format suitable for passing to CFProxyCopyProxiesForURL (with the added guarantee that no entries will ever be autoconfiguration URL entries). If an error occurs, this value will be NULL.

    error

    An error object that indicates any error that may have occurred. If no error occurred, this value will be NULL.

    Availability

    Available in iOS 2.0 and later.

Constants

  • Keys for calls to property get/set functions such as CFReadStreamSetProperty and CFReadStreamCopyProperty.

    Declaration

    Swift

    let kCFProxyAutoConfigurationHTTPResponseKey: CFString let kCFProxyAutoConfigurationJavaScriptKey: CFString let kCFProxyAutoConfigurationURLKey: CFString let kCFProxyHostNameKey: CFString let kCFProxyPasswordKey: CFString let kCFProxyPortNumberKey: CFString let kCFProxyTypeKey: CFString let kCFProxyUsernameKey: CFString

    Objective-C

    const CFStringRef kCFProxyAutoConfigurationHTTPResponseKey; const CFStringRef kCFProxyAutoConfigurationJavaScriptKey; const CFStringRef kCFProxyAutoConfigurationURLKey; const CFStringRef kCFProxyHostNameKey; const CFStringRef kCFProxyPasswordKey; const CFStringRef kCFProxyPortNumberKey; const CFStringRef kCFProxyTypeKey; const CFStringRef kCFProxyUsernameKey;

    Constants

    • kCFProxyAutoConfigurationHTTPResponseKey

      kCFProxyAutoConfigurationHTTPResponseKey

      A CFHTTPMessageRef value found in the user info dictionary of an authentication error returned to the CFNetworkCopyProxiesForAutoConfigurationScript function or to a CFProxyAutoConfigurationResultCallback callback.

      Available in iOS 2.0 and later.

    • kCFProxyAutoConfigurationJavaScriptKey

      kCFProxyAutoConfigurationJavaScriptKey

      A CFString value containing the full JavaScript source for the proxy autoconfiguration (PAC) file. This key is only present for proxies of type kCFProxyAutoConfigurationJavaScript.

      Available in iOS 3.0 and later.

    • kCFProxyAutoConfigurationURLKey

      kCFProxyAutoConfigurationURLKey

      A CFURL value specifying the location of the proxy autoconfiguration (PAC) file. This key is only present for proxies of type kCFProxyTypeAutoConfigurationURL.

      Available in iOS 2.0 and later.

    • kCFProxyHostNameKey

      kCFProxyHostNameKey

      A CFString value containing either the hostname or IP number of the proxy host.

      Available in iOS 2.0 and later.

    • kCFProxyPasswordKey

      kCFProxyPasswordKey

      The password to be used when contacting the proxy. This key is only present if the password can be determined from the information passed in. (External credential stores such as the keychain are not consulted.)

      Available in iOS 2.0 and later.

    • kCFProxyPortNumberKey

      kCFProxyPortNumberKey

      A CFNumber value specifying the port that should be used to contact the proxy.

      Available in iOS 2.0 and later.

    • kCFProxyTypeKey

      kCFProxyTypeKey

      Specifies the type of proxy. The value can be any of the values listed in Proxy Types.

      Available in iOS 2.0 and later.

    • kCFProxyUsernameKey

      kCFProxyUsernameKey

      The username to be used when contacting the proxy. This key is only present if the username can be determined from the information passed in. (External credential stores such as the keychain are not consulted.)

      Available in iOS 2.0 and later.

  • Constants that specify the type of proxy.

    Declaration

    Swift

    let kCFProxyTypeNone: CFString let kCFProxyTypeAutoConfigurationURL: CFString let kCFProxyTypeAutoConfigurationJavaScript: CFString let kCFProxyTypeFTP: CFString let kCFProxyTypeHTTP: CFString let kCFProxyTypeHTTPS: CFString let kCFProxyTypeSOCKS: CFString

    Objective-C

    const CFStringRef kCFProxyTypeNone; const CFStringRef kCFProxyTypeAutoConfigurationURL; const CFStringRef kCFProxyTypeAutoConfigurationJavaScript; const CFStringRef kCFProxyTypeFTP; const CFStringRef kCFProxyTypeHTTP; const CFStringRef kCFProxyTypeHTTPS; const CFStringRef kCFProxyTypeSOCKS;

    Constants

    • kCFProxyTypeNone

      kCFProxyTypeNone

      Specifies that no proxy should be used.

      Available in iOS 2.0 and later.

    • kCFProxyTypeAutoConfigurationURL

      kCFProxyTypeAutoConfigurationURL

      Specifies that the proxy is determined by an autoconfiguration file at a given URL.

      Available in iOS 2.0 and later.

    • kCFProxyTypeAutoConfigurationJavaScript

      kCFProxyTypeAutoConfigurationJavaScript

      Specifies that the proxy is determined by a provided autoconfiguration script.

      Available in iOS 3.0 and later.

    • kCFProxyTypeFTP

      kCFProxyTypeFTP

      Specifies an FTP proxy.

      Available in iOS 2.0 and later.

    • kCFProxyTypeHTTP

      kCFProxyTypeHTTP

      Specifies an HTTP proxy.

      Available in iOS 2.0 and later.

    • kCFProxyTypeHTTPS

      kCFProxyTypeHTTPS

      Specifies an HTTPS proxy.

      Available in iOS 2.0 and later.

    • kCFProxyTypeSOCKS

      kCFProxyTypeSOCKS

      Specifies a SOCKS proxy.

      Available in iOS 2.0 and later.

  • Constants for keys in the global proxy settings dictionary returned by CFNetworkCopySystemProxySettings.

    Declaration

    Swift

    let kCFNetworkProxiesHTTPEnable: CFString let kCFNetworkProxiesHTTPPort: CFString let kCFNetworkProxiesHTTPProxy: CFString let kCFNetworkProxiesProxyAutoConfigEnable: CFString let kCFNetworkProxiesProxyAutoConfigJavaScript: CFString let kCFNetworkProxiesProxyAutoConfigURLString: CFString

    Objective-C

    const CFStringRef kCFNetworkProxiesHTTPEnable; const CFStringRef kCFNetworkProxiesHTTPPort; const CFStringRef kCFNetworkProxiesHTTPProxy; const CFStringRef kCFNetworkProxiesProxyAutoConfigEnable; const CFStringRef kCFNetworkProxiesProxyAutoConfigJavaScript; const CFStringRef kCFNetworkProxiesProxyAutoConfigURLString;

    Constants

    • kCFNetworkProxiesHTTPEnable

      kCFNetworkProxiesHTTPEnable

      Value is a CFNumber object indicating whether an HTTP proxy is enabled. The proxy is enabled if the key is present and the associated value is nonzero.

      Available in iOS 2.0 and later.

    • kCFNetworkProxiesHTTPPort

      kCFNetworkProxiesHTTPPort

      Value is a CFNumber object containing the port number associated with the HTTP proxy.

      Available in iOS 2.0 and later.

    • kCFNetworkProxiesHTTPProxy

      kCFNetworkProxiesHTTPProxy

      Value is a CFString object containing the HTTP proxy host name or IP number.

      Available in iOS 2.0 and later.

    • kCFNetworkProxiesProxyAutoConfigEnable

      kCFNetworkProxiesProxyAutoConfigEnable

      Value is a CFNumber object indicating whether proxy autoconfiguration is enabled. Proxy autoconfiguration is enabled if the key is present and the associated value is nonzero.

      Available in iOS 2.0 and later.

    • kCFNetworkProxiesProxyAutoConfigJavaScript

      kCFNetworkProxiesProxyAutoConfigJavaScript

      Value is a CFString object that contains the full JavaScript source of the ProxyAutoConfig (PAC) file.

      Available in iOS 3.0 and later.

    • kCFNetworkProxiesProxyAutoConfigURLString

      kCFNetworkProxiesProxyAutoConfigURLString

      Value is a CFString object that contains the URL of the proxy autoconfiguration (PAC) file.

      Available in iOS 2.0 and later.