Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Networking > Core Foundation >

Downloading through a proxy server in Mac OS X


Q: Is it possible to download files through a proxy server in Mac OS X?

A: Yes, but there's some limitations. Both URL Access and CFNetwork support proxy servers. URL Access automatically uses the proxy configuration specified in the Network preference panel when downloading. However, URL Access does not support a proxy server that requires authentication, and because of a bug (r. 3197852), it doesn't support HTTPS through a proxy server.

CFNetwork does not automatically use the proxy configuration from the Network preference panel, so you'll need to apply the proxy settings to the transfer yourself. The following code snippet shows how to do this.



Listing 1. Adding proxy information from the Network preference panel to an HTTP stream.

CFDictionaryRef proxyDict = SCDynamicStoreCopyProxies(NULL);
CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxyDict);


In contrast to URL Access, CFNetwork does support proxy server authentication. In Mac OS X 10.2.x and earlier, CFNetwork did not support HTTPS through a proxy server, however, this feature is now supported in Mac OS X 10.3 and later.

Also new in Mac OS X 10.3 is the Foundation URL Loading System , which provides support for accessing resources using HTTP, HTTPS, FTP and file URLs. This Objective-C API is implemented using CFNetwork, so it supports both authenticated proxy servers and HTTPS through proxy servers.


[Oct 29, 2003]