tags:

views:

93

answers:

3

Proxy auto-configuration (PAC) files contain javascript which resolves destination hosts into proxy configuration. Clearly I could use an embedded javascript engine and provide the objects that PAC files require, but that seems like a lot of work just to resolve a proxy -- I would much rather just have a library to do it.

I'm interested in answers for any language, but especially C++ and Python.

A: 

What's your platform? On Windows, you can use WinHTTP or WinINET to do it, and there's a code sample for .NET.

EricLaw -MSFT-
A: 

HtmlUnit supports PAC, it is written in Java

Ahmed Ashour
+1  A: 

Actually you must use a Javascript engine to parse a PAC file, since it is a JS script and anything legal in JS can be in a PAC.

Some HTTP library supports PAC, such as WinHTTP and HtmlUnit suggested in other answers, but they are not dedicated for PAC and have other functions that you may not use.

I suggest you take a look at Google's pactester. It is a small Perl script using SpiderMonkey to get result from a PAC file. I think you can easily write your own python or C++ version.

Iamamac