How to use the tunnel-agent.httpOverHttp 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 aliyun-node / commands / uploader.js View on Github external
var shasum = crypto.createHash('sha1');
  shasum.update([process.env.agentid || os.hostname(), token, nonce, id].join(''));
  var sign = shasum.digest('hex');

  var url = 'http://' + server + '/files/' + id + '?nonce=' + nonce + '&sign=' + sign + '&type=' + type;

  var gateway = process.env.GATEWAY;
  if (gateway) {
    // upload to gateway
    url = 'http://' + gateway + '/file?target=' + encodeURIComponent(url);
  }

  var agent = false;
  if (process.env.http_proxy) {
    var parts = process.env.http_proxy.split(':');
    agent = tunnel.httpOverHttp({
      proxy: {
        host: parts[0],
        port: parts[1]
      }
    });
  }

  var opts = {
    dataType: 'json',
    type: 'POST',
    timeout: 60000 * 20, // 20分钟超时
    headers: form.headers(),
    stream: form,
    agent: agent
  };
github qiniu / nodejs-sdk / examples / http_https_proxy.js View on Github external
var uploadToken = putPolicy.uploadToken(mac);
var config = new qiniu.conf.Config();
// config.zone = qiniu.zone.Zone_z0;
// config.useHttpsDomain = true;
var formUploader = new qiniu.form_up.FormUploader(config);
var putExtra = new qiniu.form_up.PutExtra();

// 设置HTTP(s)代理服务器,这里可以参考:https://github.com/request/tunnel-agent
// 有几个方法:
// exports.httpOverHttp = httpOverHttp
// exports.httpsOverHttp = httpsOverHttp
// exports.httpOverHttps = httpOverHttps
// exports.httpsOverHttps = httpsOverHttps

var proxyAgent = tunnel.httpOverHttp({
    proxy: {
        host: 'localhost',
        port: 8888
    }
});

qiniu.conf.RPC_HTTP_AGENT = proxyAgent;

// qiniu.conf.RPC_HTTPS_AGENT = proxyAgent;
// 以代理方式上传
formUploader.put(uploadToken, null, 'hello', putExtra, function (respErr,
    respBody, respInfo) {
    if (respErr) {
        throw respErr;
    }
github cnpm / cnpmjs.org / common / urllib.js View on Github external
'use strict';

var urlparse = require('url').parse;
var urllib = require('urllib');
var HttpAgent = require('agentkeepalive');
var HttpsAgent = require('agentkeepalive').HttpsAgent;
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

tunnel-agent

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

Apache-2.0
Latest version published 6 years ago

Package Health Score

71 / 100
Full package analysis

Similar packages