CFNetwork is a framework which provides C APIs for common Internet protocols such as HTTP, FTP, and others. These APIs are designed with portability, performance, and consistency in mind, and are available to Cocoa and Carbon applications. CFNetwork is part of the CoreServices umbrella framework. Simply linking with CoreServices will make the CFNetwork framework available for use.
This document describes the changes in CFNetwork since Mac OS X v10.4, Tiger. Note that you may be able to find more information on many of these changes in Apple's developer documentation.
CFError
Changes in CFNetworkErrors.h for Mac OS X v10.5
New API available for Mac OS X v10.5
CFError is a new CFType introduced in CoreFoundation for reporting errors; see the CoreFoundation Framework Release Notes for more details on CFError. In Leopard, CFNetwork has adopted CFError. As such, CFNetwork provides its own error domains, error codes and user info entries in a new header file named CFNetworkErrors.h These new domains and error codes are listed below. Do reference the header file CFNetworkErrors.h for the most up to date information.
const CFStringRef kCFErrorDomainCFNetwork;
When an error of kCFHostErrorUnknown is returned, this key's value is set to a CFNumber containing the raw error value returned by getaddrinfo()
const CFStringRef kCFGetAddrInfoFailureKey;
const CFStringRef kCFSOCKSStatusCodeKey;
const CFStringRef kCFSOCKSVersionKey;
const CFStringRef kCFSOCKSNegotiationMethodKey;
const CFStringRef kCFDNSServiceFailureKey;
const CFStringRef kCFFTPStatusCodeKey;
const CFStringRef kCFFTPStatusCodeKey;
Please see Reference Library > Core Foundation for more details on the CFError type.
SInt32 CFNetServiceGetPortNumber(CFNetServiceRef theService);
Query a Network Service for its port number. The function parameter, "theService", is the Network Service instance to be queried and it must be non-NULL. It returns an SInt32 containing the port number in host byte order. On error, it returns -1 if the entity's port is not known (has not been resolved)
CFArrayRef CFNetworkCopyProxiesForURL(CFURLRef url, CFDictionaryRef proxySettings);
Given an URL and a proxy dictionary, determines the ordered list of proxies that should be used to download the given URL. The parameter, "url", specifies which CFURLRef to find proxy information for. The "proxySettings" parameter is a dictionary describing the available proxy settings; the dictionary's format should match that described in and returned by SystemConfiguration.framework. This function returns an array of dictionaries; each dictionary describes a single proxy.
CFArrayRef CFNetworkCopyProxiesForAutoConfigurationScript(CFStringRef proxyAutoConfigurationScript, CFURLRef targetURL);
Thus function executes the script given in "proxyAutoConfigurationScript", using "targetURL" as input. It will return an array of proxies as returned by the script.
CFRunLoopSourceRefCFNetworkExecuteProxyAutoConfigurationURL(CFURLRef proxyAutoConfigURL, |
CFURLRef targetURL, |
CFProxyAutoConfigurationResultCallback cb, |
CFStreamClientContext *clientContext); |
Asynchronously downloads the autoconfiguration script from the given URL, then runs that script using "targetURL" as input. Once completed, the callback "cb" is called via the run loop, passing the proxy array returned by the script. Note that the caller must schedule the returned run loop source on a running run loop in order to receive the callback.
Proxy Type Keys - see CFProxySupport.h for more details
const CFStringRef kCFProxyTypeKey; |
const CFStringRef kCFProxyTypeNone; |
const CFStringRef kCFProxyTypeHTTP; |
const CFStringRef kCFProxyTypeHTTPS; |
const CFStringRef kCFProxyTypeSOCKS; |
const CFStringRef kCFProxyTypeFTP; |
const CFStringRef kCFProxyTypeAutoConfigurationURL; |
Key for the proxy's hostname; value is a CFString. Note that this may be an IPv4 or IPv6 dotted-IP string.
const CFStringRef kCFProxyHostNameKey;
Key for the proxy's port number; value is a CFNumber specifying the port on which to contact the proxy.
const CFStringRef kCFProxyPortNumberKey;
Key for the proxy's PAC file location; this key is only present if the proxy's type is kCFProxyTypeAutoConfigurationURL. Value is a CFURL specifying the location of a proxy auto-configuration file.
const CFStringRef kCFProxyAutoConfigurationURLKey;
Key for the username to be used with the proxy; value is a CFString. Note that this key will only be present if the username could be extracted from the information passed in. No external credential stores (like the Keychain) are consulted.
const CFStringRef kCFProxyUsernameKey;
Key for the password to be used with the proxy; value is a CFString. Note that this key will only be present if the username could be extracted from the information passed in. No external credential stores (like the Keychain) are consulted.
const CFStringRef kCFProxyPasswordKey;
Stream property key, for copy operations. The value is the CFHTTPMessage transmitted by the stream, after all modifications (such as for authentication, connection policy, or redirection) have been made.
const CFStringRef kCFStreamPropertyHTTPFinalRequest;
These two strings represent authentication methods that are supported in CFNetwork.
const CFStringRef kCFHTTPAuthenticationSchemeNTLM;
const CFStringRef kCFHTTPAuthenticationSchemeNegotiate;
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)
|