How to use the tunnel-agent.httpsOverHttp function in tunnel-agent

To help you get started, we’ve selected a few tunnel-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / test / run-integration.js View on Github external
server.listen(0, function() {
    var tunnel = require('tunnel-agent');

    var agentSettings = {
      proxy: {
        host: server.address().host,
        port: server.address().port
      }
    };

    var proxyClient = algoliasearch(appId, apiKey, {
      httpAgent: tunnel.httpsOverHttp(agentSettings)
    });
    var proxyIndex = proxyClient.initIndex(indexName);
    proxyIndex
      .browse()
      .then(end)
      .then(null, _.bind(t.error, t));

    function end(content) {
      server.close();
      proxyClient.destroy();
      t.ok(content.hits.length, 'We got some content');
    }
  });
}
github DevExpress / testcafe-hammerhead / src / request-pipeline / destination-request / agent.ts View on Github external
export function assign (reqOpts: RequestOptions): void {
    const proxy = reqOpts.proxy;

    if (proxy && reqOpts.protocol === 'https:') {
        reqOpts.agent = tunnel.httpsOverHttp({
            proxy,
            rejectUnauthorized: false
        });

        return;
    }

    let type = '';

    if (reqOpts.protocol === 'http:')
        type = TYPE.HTTP;

    else if (ssl3HostCache.get(reqOpts.host))
        type = TYPE.SSL3;

    else
github faye / faye / src / transport / node_http.js View on Github external
}

    var options = assign({
      proxy: {
        host:       this._proxyUri.hostname,
        port:       this._proxyUri.port || this.DEFAULT_PORTS[this._proxyUri.protocol],
        proxyAuth:  this._proxyUri.auth,
        headers:    assign({ host: this.endpoint.host }, proxy.headers)
      }
    }, this._dispatcher.tls);

    if (this._proxySecure) {
      assign(options.proxy, proxy.tls);
      this._tunnel = tunnel.httpsOverHttps(options);
    } else {
      this._tunnel = tunnel.httpsOverHttp(options);
    }
  },
github heroku / cli / packages / heroku-local / lib / download.js View on Github external
return new Promise(function (fulfill, reject) {
    let httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
    let agent;
    if (httpsProxy) {
      cli.hush(`proxy set to ${httpsProxy}`);
      let proxy = url.parse(httpsProxy);

      agent = tunnel.httpsOverHttp({
        proxy: {
          host: proxy.hostname,
          port: proxy.port || 8080
        }
      });
    } else {
      agent = new https.Agent();
    }

    let requestOptions = url.parse(urlStr);
    requestOptions.agent = agent;

    let req = https.request(requestOptions, function (res) {
      if (res.statusCode > 200 || res.statusCode >= 300) return reject(new Error(res.body));
      res.pipe(fs.createWriteStream(tmpPath, opts));
      res.on('end', fulfill);
github wuchangming / node-mitmproxy / src / common / util.js View on Github external
util.getTunnelAgent = (requestIsSSL, externalProxyUrl) => {
    var urlObject = url.parse(externalProxyUrl);
    var protocol = urlObject.protocol || 'http:';
    var port = urlObject.port;
    if (!port) {
        port = protocol === 'http:' ? 80 : 443;
    }
    var hostname = urlObject.hostname || 'localhost';

    if (requestIsSSL) {
        if (protocol === 'http:') {
            if (!httpsOverHttpAgent) {
                httpsOverHttpAgent = tunnelAgent.httpsOverHttp({
                    proxy: {
                        host: hostname,
                        port: port
                    }
                });
            }
            return httpsOverHttpAgent
        } else {
            if (!httpsOverHttpsAgent) {
                httpsOverHttpsAgent = tunnelAgent.httpsOverHttps({
                    proxy: {
                        host: hostname,
                        port: port
                    }
                });
            }
github cnpm / cnpmjs.org / common / urllib.js View on Github external
var config = require('../config');

var httpAgent;
var httpsAgent;

if (config.httpProxy) {
  var tunnel = require('tunnel-agent');
  var urlinfo = urlparse(config.httpProxy);
  if (urlinfo.protocol === 'http:') {
    httpAgent = tunnel.httpOverHttp({
      proxy: {
        host: urlinfo.hostname,
        port: urlinfo.port
      }
    });
    httpsAgent = tunnel.httpsOverHttp({
      proxy: {
        host: urlinfo.hostname,
        port: urlinfo.port
      }
    });
  } else if (urlinfo.protocol === 'https:') {
    httpAgent = tunnel.httpOverHttps({
      proxy: {
        host: urlinfo.hostname,
        port: urlinfo.port
      }
    });
    httpsAgent = tunnel.httpsOverHttps({
      proxy: {
        host: urlinfo.hostname,
        port: urlinfo.port

tunnel-agent

HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.

Apache-2.0
Latest version published 8 years ago

Package Health Score

71 / 100
Full package analysis