Log in

View Full Version : HTTP and proxies?


Punchey
01-27-2004, 07:17 AM
I use some in-app routines to retrieve various dynamic information from my website such as the most recent version number, current special offers, etc. But I'm having trouble with a proxy issue.

To detect proxy settings, I lookup "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" and read in the "Proxy Enable" value. If enabled, I read the "ProxyServer" string which normally contains either a hostname or an ip : port pair. Normally my app reads in the proxy's IP or hostname, connects to it, and then submits the HTTP request to it. But here's the trouble I'm having:

An app called "AdSubtract" which filters HTTP traffic for banner ads sets itself up as the proxy server for the machine, filters the traffic, and then forwards all traffic to the actual proxy server. It does this by replacing the actual proxy entry in the registry with its own hostname. This worked in the previous version where it used a hostname like "adsubtract". My app would connect to this hostname sucessfully and everything was properly forwarded. But in the latest version, AdSubtract now places "localhost:<port>" (where <port> is a port number the application uses) in the registry. This doesn't seem to resolve properly and my app can never establish a connection whith this "address". I'm kinda new to this whole thing, is there something I'm missing? Any tips? Thanks!

princec
01-27-2004, 08:23 AM
Check that AdSubtract is actually listening on that port (netstat -a) and also that it is in fact configured as the proxy.

Cas :)

Larry Hastings
01-27-2004, 09:00 AM
My understanding is that the Windows Internet API (InternetOpen() and the like) automatically uses the proxy settings from Internet Explorer. So if you wanted to be totally safe, I'm pretty sure you could stick with those and get the proxy stuff for free.

Punchey
01-27-2004, 09:40 AM
princec: I'll check that, but I'm pretty sure it is. If not, they've got a crappy piece of software! :)

Larry Hastings: Yeah, I had looked into InternetOpen() etc back when I first developed all of this stuff, but it looked excessively complex to use. Is that incorrect? Is it pretty easy to do POST arguments, etc, with it?

Pyabo
01-27-2004, 12:26 PM
Punchey, it's quite easy and will transparently handle requests through the proxy for you. Look in MSDN for HttpOpenRequest() and HttpSendRequest(). Also, you could probably find plenty of sample code on codeproject.com.