curl-library
Proxy discovery
Date: Tue, 13 Mar 2007 09:28:04 -0400
Does anyone have any, or know of any, sample code to do proxy
discovery, esp. if it was on Windows and used the InternetQueryOption
to get IE's proxy options? We'd rather not put in a whole set of
our own proxy settings, and just get the Windows ones. I have this code:
LPINTERNET_PROXY_INFO lipi((LPINTERNET_PROXY_INFO)new char[sizeof(INTERNET_PROXY_INFO)]);
DWORD sipi=sizeof(INTERNET_PROXY_INFO);
while ( !InternetQueryOption(0,INTERNET_OPTION_PROXY,lipi,&sipi ) )
{
delete[] lipi;
if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
{ // we need more room
lipi = (LPINTERNET_PROXY_INFO)new char[sipi];
}
else
{
return false;
}
}
bool use_proxy = ( lipi->dwAccessType == INTERNET_OPEN_TYPE_PROXY && lipi->lpszProxy != NULL );
if ( use_proxy )
{
proxy = lipi->lpszProxy;
}
delete[] lipi;
return use_proxy;
but it is too simplistic and doesn't cover the case with special exceptions and to
not use the proxy for local IPs. It all seems a real pain in the neck and I was
hoping someone else had already solved this!
-- Jonathan Arnold Software Engineer inSORS Integrated Communications, Inc jarnold_at_insors.com Office/fax: 781.391.2818Received on 2007-03-13