How to get proxy settings for use with CFStream?
How to get proxy settings for use with CFStream?
- Subject: How to get proxy settings for use with CFStream?
- From: Jens Alfke <email@hidden>
- Date: Tue, 28 May 2013 12:51:02 -0700
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:
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden