/** * Usage example of the `HttpsProxyAgent` class proxying an * HTTPS (SSL) endpoint over an HTTP(s) proxy. */ var url = require('url'); var https = require('https'); var HttpsProxyAgent = require('./https-proxy-agent'); // HTTP proxy to connect to var proxy = process.env.http_proxy || 'http://168.63.76.32:3128'; console.log('using proxy server %j', proxy); proxy = url.parse(proxy); // HTTPS endpoint for the proxy to connect to var endpoint = process.argv[2] || 'https://gist.github.com/TooTallNate/5952254/raw/07972db49b5b70a212c39dfee56ed3ab82f8179c/agent.js'; console.log('attempting to GET %j', endpoint); var opts = url.parse(endpoint); // create an instance of the `HttpsProxyAgent` class with the proxy server information opts.agent = new HttpsProxyAgent(proxy); https.get(opts, function (res) { console.log('"response" event!', res.headers); res.pipe(process.stdout); });