Re: How to get proxy settings for use with CFStream?
Not my area of expertise, so I’m a little fuzzy on the details, but maybe this will give you a hint that will help. Some proxy settings may involve running a java script to evaluate what proxy to use. I think that’s what kCFProxyTypeAutoConfigurationURL means. You may need to use something like CFNetworkCopyProxiesForAutoConfigurationScript to run the script. If there’s any way you can use NSURLRequest/NSURLConnection instead, the world of hurt known as proxies will no longer be your problem :) -josh On May 28, 2013, at 12:51 PM, Jens Alfke <jens@mooseyard.com> wrote:
I have some code that uses CFReadStreamCreateForHTTPRequest to send an HTTP request. I have a bug report that this fails with a POSIX error 60 (ECONN) in an environment where a proxy server has to be used to reach outside HTTP servers. I looked at the docs and sure ‘nuf, CFStream doesn’t use the system proxy settings the way NSURLConnection does. Crap.
I added the following code, but the user reports that it still doesn’t work for him:
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings(); if (proxySettings) { CFArrayRef proxies = CFNetworkCopyProxiesForURL((__bridge CFURLRef)url, proxySettings); if (CFArrayGetCount(proxies) > 0) { CFTypeRef proxy = CFArrayGetValueAtIndex(proxies, 0); NSLog(@"Changes feed using proxy %@", proxy); bool ok = CFReadStreamSetProperty(cfInputStream, kCFStreamPropertyHTTPProxy, proxy); Assert(ok); CFRelease(proxies); } CFRelease(proxySettings); }
The output of that NSLog shows that the proxy dictionary he’s getting is:
{ kCFProxyAutoConfigurationURLKey = "http://bgproxy.XXXX/wpad.dat"; kCFProxyTypeKey = kCFProxyTypeAutoConfigurationURL; }
This doesn’t look right. It’s a specification of where to read the proxy settings from, not an actual proxy setting, and it doesn’t match the proxy keys defined in the CFStream documentation (i.e. “kCFStreamPropertySOCKS*”.) So how do I get the actual proxy settings?
(This is complicated by the fact that I don’t have access to a firewalled network that uses an HTTP proxy, so I can’t reproduce the problem directly.)
—Jens _______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/macnetworkprog/jgraessley%40apple.co...
This email sent to jgraessley@apple.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/macnetworkprog/site_archiver%40lists... This email sent to site_archiver@lists.apple.com
participants (1)
-
Josh Graessley