Discussion:
WinHttpGetProxyForUrl returns error 12006
(too old to reply)
Sunny
2008-09-09 14:31:02 UTC
Permalink
Hi,
I have a situation, in which the proxy.pac file is deployed locally on the
users' hard drives, and not on a web server. I.e. the IE setting for the
proxy.pac url looks like: file://C:/somefolder/proxy.pac

IE works OK with that setting, and succeeds to fetch and use the proxy, but
when I pass this to WinHttpGetProxyForUrl to get the real proxy server, the
function fails with error 12006 (ERROR_WINHTTP_UNRECOGNIZED_SCHEME).
According to the documentation found here:
http://msdn.microsoft.com/en-us/library/aa384097(VS.85).aspx
this error means: "The URL of the PAC file specified a scheme other than
"http:" or "https:".

So, what other function I can use to get the right proxy server for a given
url from a locally deployed proxy.pac?

Thanks
Eric Loewenthal
2008-10-07 05:30:01 UTC
Permalink
Hi Sunny,

Unfortunately the error message you are receiving meens exactly what it says
it means. WinHttpGetProxyForUrl and WinINET proxy download are basically
mini file download apps that use the respective stack's functionality. In
this case WinHttpGetProxyForUrl will use WinHttpSendRequest while WinINET
uses InternetOpenUrl. Writing these sample apps you will notice that
WinHttpSendRequest does not support the file:// 'scheme' while
InternetOpenUrl does. As such, WinINET supports local .pac files but WinHTTP
does not. There is no current workaround aside from moving the .pac file
onto a web server or using WinINET as your Http stack.

Let me know if you have any followup questions.

Thanks,

Eric Loewenthal
Post by Sunny
Hi,
I have a situation, in which the proxy.pac file is deployed locally on the
users' hard drives, and not on a web server. I.e. the IE setting for the
proxy.pac url looks like: file://C:/somefolder/proxy.pac
IE works OK with that setting, and succeeds to fetch and use the proxy, but
when I pass this to WinHttpGetProxyForUrl to get the real proxy server, the
function fails with error 12006 (ERROR_WINHTTP_UNRECOGNIZED_SCHEME).
http://msdn.microsoft.com/en-us/library/aa384097(VS.85).aspx
this error means: "The URL of the PAC file specified a scheme other than
"http:" or "https:".
So, what other function I can use to get the right proxy server for a given
url from a locally deployed proxy.pac?
Thanks
Sunny
2008-10-07 13:36:02 UTC
Permalink
This post might be inappropriate. Click to display it.
Eric Loewenthal
2008-10-10 21:54:01 UTC
Permalink
Hi Sunny,

Are you running as a client app running as the interactive user or a service
impersonating the caller?

Thanks,

Eric Loewenthal
Post by Sunny
Post by Eric Loewenthal
Hi Sunny,
Unfortunately the error message you are receiving meens exactly what it says
it means. WinHttpGetProxyForUrl and WinINET proxy download are basically
mini file download apps that use the respective stack's functionality. In
this case WinHttpGetProxyForUrl will use WinHttpSendRequest while WinINET
uses InternetOpenUrl. Writing these sample apps you will notice that
WinHttpSendRequest does not support the file:// 'scheme' while
InternetOpenUrl does. As such, WinINET supports local .pac files but WinHTTP
does not. There is no current workaround aside from moving the .pac file
onto a web server or using WinINET as your Http stack.
Let me know if you have any followup questions.
Thanks,
Eric Loewenthal
Hi Eric,
thanks for the answer. Anyway, I have no control over client's environment,
and I can not tell them how to deploy their setup. I see that IE can cope
somehow with file:// setting, so is there any other API (even part of the IE
object model) which I can use to get the information needed?
Thanks again
Sunny
Sunny
2008-10-13 13:40:01 UTC
Permalink
Post by Eric Loewenthal
Hi Sunny,
Are you running as a client app running as the interactive user or a service
impersonating the caller?
Hi Eric,
this is a client app, running as interactive user.

Thanks
Sunny
Eric Loewenthal
2008-11-10 06:41:01 UTC
Permalink
Hi Sunny,

Sorry for the delayed response.

If you must find a way to support the local proxy scripts you can use
wininet.dll proxy functionality. As MSDN states, it is recommended you use
WinHTTP and these older wininet APIs are not nearly as feature rich. As
such, I would recommend calling the WinHTTP API first for each URL and only
upon failure for that URL would I call the WinINET version.

The functions you will need are
First call InternetInitializeAutoProxyDll
http://msdn.microsoft.com/en-us/library/aa385093(VS.85).aspx

Second call InternetGetProxyInfo
http://msdn.microsoft.com/en-us/library/aa384726.aspx

Finally call InternetDeInitializeAutoProxyDll
http://msdn.microsoft.com/en-us/library/aa384580(VS.85).aspx

As you see on MSDN you need to LoadLib jsproxy and GetProcAddress these
functions.

There is a sample here:
http://msdn.microsoft.com/en-us/library/aa383910(VS.85).aspx to help you get
started. The sample looks like it is missing an entry in the Vtbl
declaration, there should be 9 functions.

Note that if you need IPv6 support you will need to provide an Ex version of
the IPv4 functions in the sample.

Thanks,

Eric Loewenthal
***@microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Sunny
Post by Eric Loewenthal
Hi Sunny,
Are you running as a client app running as the interactive user or a service
impersonating the caller?
Hi Eric,
this is a client app, running as interactive user.
Thanks
Sunny
Loading...