Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
test/ | 12-May-2024 | - | 333 | 272 | ||
.travis.yml | D | 12-May-2024 | 292 | 23 | 15 | |
History.md | D | 12-May-2024 | 2.5 KiB | 102 | 73 | |
README.md | D | 12-May-2024 | 2.4 KiB | 75 | 55 | |
index.js | D | 12-May-2024 | 3.4 KiB | 112 | 61 | |
package.json | D | 12-May-2024 | 1.8 KiB | 68 | 67 |
README.md
1 http-proxy-agent 2 ================ 3 ### An HTTP(s) proxy `http.Agent` implementation for HTTP 4 [](https://travis-ci.org/TooTallNate/node-http-proxy-agent) 5 6 This module provides an `http.Agent` implementation that connects to a specified 7 HTTP or HTTPS proxy server, and can be used with the built-in `http` module. 8 9 __Note:__ For HTTP proxy usage with the `https` module, check out 10 [`node-https-proxy-agent`](https://github.com/TooTallNate/node-https-proxy-agent). 11 12 Installation 13 ------------ 14 15 Install with `npm`: 16 17 ``` bash 18 $ npm install http-proxy-agent 19 ``` 20 21 22 Example 23 ------- 24 25 ``` js 26 var url = require('url'); 27 var http = require('http'); 28 var HttpProxyAgent = require('http-proxy-agent'); 29 30 // HTTP/HTTPS proxy to connect to 31 var proxy = process.env.http_proxy || 'http://168.63.76.32:3128'; 32 console.log('using proxy server %j', proxy); 33 34 // HTTP endpoint for the proxy to connect to 35 var endpoint = process.argv[2] || 'http://nodejs.org/api/'; 36 console.log('attempting to GET %j', endpoint); 37 var opts = url.parse(endpoint); 38 39 // create an instance of the `HttpProxyAgent` class with the proxy server information 40 var agent = new HttpProxyAgent(proxy); 41 opts.agent = agent; 42 43 http.get(opts, function (res) { 44 console.log('"response" event!', res.headers); 45 res.pipe(process.stdout); 46 }); 47 ``` 48 49 50 License 51 ------- 52 53 (The MIT License) 54 55 Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net> 56 57 Permission is hereby granted, free of charge, to any person obtaining 58 a copy of this software and associated documentation files (the 59 'Software'), to deal in the Software without restriction, including 60 without limitation the rights to use, copy, modify, merge, publish, 61 distribute, sublicense, and/or sell copies of the Software, and to 62 permit persons to whom the Software is furnished to do so, subject to 63 the following conditions: 64 65 The above copyright notice and this permission notice shall be 66 included in all copies or substantial portions of the Software. 67 68 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 69 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 70 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 71 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 72 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 73 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 74 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 75