Re: Proxy Problem with CFNetwork
Re: Proxy Problem with CFNetwork
- Subject: Re: Proxy Problem with CFNetwork
- From: Marc Krochmal <email@hidden>
- Date: Wed, 29 Oct 2003 12:38:50 -0800
Hi Dan,
HTTPS through a proxy server was broken on Mac OS X 10.2 but it should
work in 10.3. Here's a recently posted Q&A on the subject...
<
http://developer.apple.com/qa/qa2001/qa1296.html>
-Marc
On Oct 29, 2003, at 4:19 AM, Daniel Zimmerman wrote:
I'm following the recommended method of setting the Proxy server when
using CFNetwork with OS 10.2+ for my https POST requests, but I'm not
seeing it use the proxy server. My requests are not showing up in
the access log of the proxy server, so I don't think it's being set
properly. (Hitting my https servlet with Safari does show up in the
access log).
I'm creating an CFHTTPMessageRef using CFHTTPMessageCreateRequest()
passing in my https url and POST for the method. I then set some
headers and call CFReadStreamCreateForHTTPRequest to create a stream.
Once I have the stream, here's how I'm setting the proxy settings:
CFDictionaryRef theProxyDict = SCDynamicStoreCopyProxies(NULL);
if (theProxyDict != NULL) {
CFReadStreamSetProperty(my_stream, kCFStreamPropertyHTTPProxy,
theProxyDict);
}
Then I do a CFReadStreamOpen(my_stream), but it does not make the
connection to the proxy server.
I verified that the Dictionary that is returned from
SCDynamicStoreCopyProxies() does in fact have a key for the HTTPS
proxy host and port.
I also tried setting the proxy settings using the following code as
well with no better luck:
CFStringRef proxyHostRef = CFStringCreateWithCString(NULL, (const
char *)&proxyHost, kCFStringEncodingMacRoman);
CFReadStreamSetProperty(my_stream, kCFStreamPropertyHTTPSProxyHost,
proxyHostRef);
SInt32 proxyPortFull = proxyPort;
CFNumberRef proxyPortRef = CFNumberCreate(NULL, kCFNumberSInt32Type,
&proxyPortFull);
CFReadStreamSetProperty(my_stream, kCFStreamPropertyHTTPSProxyPort,
proxyPortRef);
I even tried creating a whole new Dictionary, by pulling out the
ProxyHost and ProxyPort key/value pair from the dictionary returned by
SCDynamicStoreCopyProxies() and then using the newly created
dictionary to set the proxy property, but that did not work either.
I don't understand why this is not working like it is described in the
documentation. Am I doing anything wrong here? Anyone have some
sample code that does this?
In the past when I've written code that talked to proxy servers, I
used the mechanism of opening a connection to the proxy server and
then requesting the full https://.... url. When I saw that with 10.2+
you simply had to set some property on the stream, I thought it was
going to be simple....
Thanks,
Dan
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.