Re: Proxy Problem with CFNetwork
Re: Proxy Problem with CFNetwork
- Subject: Re: Proxy Problem with CFNetwork
- From: Daniel Zimmerman <email@hidden>
- Date: Wed, 29 Oct 2003 14:41:45 -0800
Marc,
Knowing it's a bug means that I won't need to spend anymore time
trying to figure out why my code doesn't work, but now that I've
switched to use CFNetwork instead of URLAccess (so I could use HTTPS
proxy support), it looks like I'll have to go down a level and use an
API that let's me control it myself. The Q&A doc you reference didn't
have any suggestions on what to do next if you need this support, so
where should I look for this support on 10.2? Safari obviously works
on 10.2 so it must be using a lower level API on 10.2.
All I need is a single HTTPS Post to be made with some headers going
in and out. It shouldn't be this difficult and if it wasn't for the
proxy problem, this is a simple thing to do. I probably couldn't get
away with having a "bug" on 10.2 regarding this, so I'd like to find a
way to get this one call working with a proxy server.
Thanks
Dan
On Oct 29, 2003, at 12:38 PM, Marc Krochmal wrote:
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.