On Jul 17, 2014, at 4:48 AM, Daryle Walker <email@hidden> wrote:
Just inspected an open-source program with this need. The code for the raw request and response is preceded by an IF block, testing if there’s proxy settings, to send the CONNECT command. (There’s no string building; the author printfs the HTTP request block right to the stream and scanfs the response to look for the 200 and blow through the rest.) So reuse should be possible, just need to create the CFStream before calling the CFHTTP code so I can still use the CFStream after the HTTP stuff.
I’ve been checking more of Apple’s docs, and I notice:
CFDictionaryRef proxyDict = SCDynamicStoreCopyProxies(NULL); | CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxyDict); |
If that code would work, I think I can use it for HTTP and SOCKS proxies. (And FTP theoretically too, but I’ll skip that since native FTP proxies are specifically for FTP and aren’t usable by other protocols.) Can this technique work for the automatic-configuration (URL/_javascript_) proxy types?
On another note, I read NSURLProtocol, and I’m wondering where the network code actually goes. Putting it in startLoading: would cause reentry issues with stopLoading: (and blocking). I guess I could implement with NSOperations (and queue) or NSStream delegates, doing the setup in startLoading:.
— Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
|