README.md
1 pac-proxy-agent 2 =============== 3 ### A [PAC file][pac-wikipedia] proxy `http.Agent` implementation for HTTP and HTTPS 4 [](https://github.com/TooTallNate/node-pac-proxy-agent/actions?workflow=Node+CI) 5 6 This module provides an `http.Agent` implementation that retreives the specified 7 [PAC proxy file][pac-wikipedia] and uses it to resolve which HTTP, HTTPS, or 8 SOCKS proxy, or if a direct connection should be used to connect to the 9 HTTP endpoint. 10 11 It is designed to be be used with the built-in `http` and `https` modules. 12 13 14 Installation 15 ------------ 16 17 Install with `npm`: 18 19 ``` bash 20 $ npm install pac-proxy-agent 21 ``` 22 23 24 Example 25 ------- 26 27 ``` js 28 var url = require('url'); 29 var http = require('http'); 30 var PacProxyAgent = require('pac-proxy-agent'); 31 32 // URI to a PAC proxy file to use (the "pac+" prefix is stripped) 33 var proxy = 'pac+https://cloudup.com/ceGH2yZ0Bjp+'; 34 console.log('using PAC proxy proxy file at %j', proxy); 35 36 // HTTP endpoint for the proxy to connect to 37 var endpoint = 'http://nodejs.org/api/'; 38 console.log('attempting to GET %j', endpoint); 39 var opts = url.parse(endpoint); 40 41 // create an instance of the `PacProxyAgent` class with the PAC file location 42 var agent = new PacProxyAgent(proxy); 43 opts.agent = agent; 44 45 http.get(opts, function (res) { 46 console.log('"response" event!', res.headers); 47 res.pipe(process.stdout); 48 }); 49 ``` 50 51 52 License 53 ------- 54 55 (The MIT License) 56 57 Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net> 58 59 Permission is hereby granted, free of charge, to any person obtaining 60 a copy of this software and associated documentation files (the 61 'Software'), to deal in the Software without restriction, including 62 without limitation the rights to use, copy, modify, merge, publish, 63 distribute, sublicense, and/or sell copies of the Software, and to 64 permit persons to whom the Software is furnished to do so, subject to 65 the following conditions: 66 67 The above copyright notice and this permission notice shall be 68 included in all copies or substantial portions of the Software. 69 70 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 71 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 72 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 73 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 74 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 75 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 76 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 77 78 [pac-wikipedia]: http://wikipedia.org/wiki/Proxy_auto-config