Re: Proxy Problem with CFNetwork
Re: Proxy Problem with CFNetwork
- Subject: Re: Proxy Problem with CFNetwork
- From: James Masasaki <email@hidden>
- Date: Wed, 29 Oct 2003 10:08:35 -0800
Hi Dan,
It seems everyone I talk too is having this same problem. It simply
does not work the way it is supposed to. I am working on this problem
but from a different angle: I want to set the proxy settings in
System Preferences. I have tried several approaches but to no avail.
Apple's documentation on this subject is ABYSMAL. I have a support
incident into DTS and we will see what they say.
Best Regards,
James
At 4:19 AM -0800 10/29/03, 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.