Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WinHttpGetProxyForUrl returns error 12006

2,076 views
Skip to first unread message

Sunny

unread,
Sep 9, 2008, 10:31:02 AM9/9/08
to
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

unread,
Oct 7, 2008, 1:30:01 AM10/7/08
to
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
eri...@microsoft.com

Sunny

unread,
Oct 7, 2008, 9:36:02 AM10/7/08
to

"Eric Loewenthal" wrote:

> 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
> eri...@microsoft.com
>

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

Eric Loewenthal

unread,
Oct 10, 2008, 5:54:01 PM10/10/08
to
Hi Sunny,

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

Thanks,

Eric Loewenthal
eri...@microsoft.com

Sunny

unread,
Oct 13, 2008, 9:40:01 AM10/13/08
to

"Eric Loewenthal" wrote:

> 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

Loewenthal@discussions.microsoft.com Eric Loewenthal

unread,
Nov 10, 2008, 1:41:01 AM11/10/08
to
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
eri...@microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages