views:

96

answers:

1

Proxy Auto Config (PAC) is the traditional method by which web-browsers are automatically configured to use the appropriate proxy for any given site. PAC files consist of a single function implemented in JavaScript.

I'd like to execute this function for another puropose: I'm trying to make an application which selects a proxy to use in exactly the same way that Microsoft Internet Explorer might do. Since I cannot simply ask IE what proxy it would use for a particular site, I'm trying to emulate what IE would do when it selects which proxy to use for a given web-resource.

It's easy to call a JS function with Windows Scripting host, but in order to execute a PAC file I need a few standard functions such as shExpMatch and isPlainHostName. These are usually provided by the browser. Firefox provides this file in an easy to use JS file - unfortunately the FF implementation does not seem to be perfectly compatible with Microsoft's implementation of Javascript.

I need to find where the official microsoft implementations of these functions are so that I can include them in my scripting environment before trying to call the function.

Any ideas where these might be?

Thanks

Update 0: I found a documented microsoft function which might do what I need - thr question is how can I call this from Win32Com in Python 2.4.4?

+2  A: 

I don't know where the actual implementation is, however Microsoft have provided code that you can call that replicates the functionality in the .NET framework, in the System.Net namespace.

The class is called WebProxyScriptHelper, but unfortunately it is set to internal visibility so you can't call it directly (you don't say what language you are using so this may not even be an option). Fortunately, Microsoft have made the source code available anyway.

Edited to add:

There is also a Windows API function, WinHttpGetProxyForUrl. Perhaps this is what you should be using instead?

Jon Grant
I found something which might be helpful: http://stackoverflow.com/questions/1078939/id-like-to-call-the-windows-c-call-winhttpgetproxyforurl-from-python-can-thiI added an update which answers your questions.
Salim Fadhley