WMCC RPC client.
@alias module:http.RPCClient
@constructor
@param {String} uri
@param {Object?} options
541343
function RPCClient(options) {
  if (!(this instanceof RPCClient))
    return new RPCClient(options);

  if (!options)
    options = {};

  if (typeof options === 'string')
    options = { uri: options };

  this.options = options;
  this.network = Network.get(options.network);

  this.uri = options.uri || `http://localhost:${this.network.rpcPort}`;
  this.apiKey = options.apiKey;
  this.id = 0;
}
179061
function HttpServer(options) {
  options = options || {};

  if (options.root) {
    this.root = options.root;
  }
  else {
    try {
      fs.lstatSync('./public');
      this.root = './public';
    }
    catch (err) {
      this.root = './';
    }
  }

  this.headers = options.headers || {};

  this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
  this.showDir = options.showDir !== 'false';
  this.autoIndex = options.autoIndex !== 'false';
  this.gzip = options.gzip === true;
  this.contentType = options.contentType || 'application/octet-stream';

  if (options.ext) {
    this.ext = options.ext === true
      ? 'html'
      : options.ext;
  }

  var before = options.before ? options.before.slice() : [];

  before.push(function (req, res) {
    if (options.logFn) {
      options.logFn(req, res);
    }

    res.emit('next');
  });

  if (options.cors) {
    this.headers['Access-Control-Allow-Origin'] = '*';
    this.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Range';
    if (options.corsHeaders) {
      options.corsHeaders.split(/\s*,\s*/)
          .forEach(function (h) { this.headers['Access-Control-Allow-Headers'] += ', ' + h; }, this);
    }
    before.push(corser.create(options.corsHeaders ? {
      requestHeaders: this.headers['Access-Control-Allow-Headers'].split(/\s*,\s*/)
    } : null));
  }

  if (options.robots) {
    before.push(function (req, res) {
      if (req.url === '/robots.txt') {
        res.setHeader('Content-Type', 'text/plain');
        var robots = options.robots === true
          ? 'User-agent: *\nDisallow: /'
          : options.robots.replace(/\\n/, '\n');

        return res.end(robots);
      }

      res.emit('next');
    });
  }

  before.push(ecstatic({
    root: this.root,
    cache: this.cache,
    showDir: this.showDir,
    autoIndex: this.autoIndex,
    defaultExt: this.ext,
    gzip: this.gzip,
    contentType: this.contentType,
//    handleError: typeof options.proxy !== 'string'
    handleError: (!options.fallback || typeof options.proxy === 'string')
  }));

  if (typeof options.proxy === 'string') {
    var proxy = httpProxy.createProxyServer({});
    before.push(function (req, res) {
      proxy.web(req, res, {
        target: options.proxy,
        changeOrigin: true
      });
    });
  }

  if (options.fallback) {
    before.push(function (req, res) {
      if (res.statusCode === 404) {
        res.redirect(options.fallback.address, 301);
      }
    });
  }

  var serverOptions = {
    before: before,
    headers: this.headers,
    onError: function (err, req, res) {
      if (options.logFn) {
        options.logFn(req, res, err);
      }

      res.end();
    }
  };

  if (options.https) {
    serverOptions.https = options.https;
  }

  this.server = union.createServer(serverOptions);
}
42150
function SimpleClient(options) {
    options = options || {};
    this.client = new Zookeeper(options);
    this.root = options.root || '/';
  }
1086160
function WebClientConnection(options) {

    var url = window.location.host.split(':')[0];
    if (options && options.proxyUrl) {
        url = options.proxyUrl;
    }

    this.createProxySocket('http://' + url, 33331);

    EventEmitter.call(this);
}
741004
public static WebsocketClientTransport create(URI uri) {
    Objects.requireNonNull(uri, "uri must not be null");

    TcpClient client = createClient(uri);
    return create(HttpClient.from(client), uri.getPath());
  }
975365
function WebRtcPeerRecvonly(options, callback) {
  if (!(this instanceof WebRtcPeerRecvonly)) {
    return new WebRtcPeerRecvonly(options, callback)
  }

  WebRtcPeerRecvonly.super_.call(this, 'recvonly', options, callback)
}
1349557
function CubxHttpServer (options) {
  options = options || {};

  if (options.root) {
    this.root = options.root;
  } else {
    try {
      fs.lstatSync('./public');
      this.root = './public';
    } catch (err) {
      this.root = './';
    }
  }

  this.headers = options.headers || {};

  this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
  this.showDir = options.showDir !== 'false';
  this.autoIndex = options.autoIndex !== 'false';
  this.contentType = options.contentType || 'application/octet-stream';

  if (options.ext) {
    this.ext = options.ext === true
      ? 'html'
      : options.ext;
  }

  var before = options.before ? options.before.slice() : [];

  before.push(function (req, res) {
    if (options.logFn) {
      options.logFn(req, res);
    }
    res.emit('next');
  });

  if (options.cors) {
    this.headers[ 'Access-Control-Allow-Origin' ] = '*';
    this.headers[ 'Access-Control-Allow-Headers' ] = 'Origin, X-Requested-With, Content-Type, Accept, Range';
    if (options.corsHeaders) {
      options.corsHeaders.split(/\s*,\s*/)
        .forEach(function (h) { this.headers[ 'Access-Control-Allow-Headers' ] += ', ' + h; }, this);
    }
    before.push(corser.create(options.corsHeaders ? { requestHeaders: this.headers[ 'Access-Control-Allow-Headers' ].split(/\s*,\s*/) } : null));
  }

  if (options.robots) {
    before.push(function (req, res) {
      if (req.url === '/robots.txt') {
        res.setHeader('Content-Type', 'text/plain');
        var robots = options.robots === true
          ? 'User-agent: *\nDisallow: /'
          : options.robots.replace(/\\n/, '\n');

        return res.end(robots);
      }

      res.emit('next');
    });
  }

  // remove simulated store from url path
  before.push(function (req, res) {
    storeRemover.resolve(req, res);
  });

  // resolving local webpackages
  resolver.init(this.root);
  before.push(function (req, res) {
    resolver.resolve(req, res);
  });

  before.push(ecstatic({
    root: this.root,
    cache: this.cache,
    showDir: this.showDir,
    autoIndex: this.autoIndex,
    defaultExt: this.ext,
    contentType: this.contentType,
    handleError: typeof options.proxy !== 'string'
  }));

  if (typeof options.proxy === 'string') {
    if (!options.npu) {
      var npuHttpProxy = process.env.http_proxy || process.env.HTTP_PROXY || null;

      var npuHttpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY || null;

      if (options.proxy.indexOf('https:') === 0 && npuHttpsProxy && !this.isInNoProxyConfig(options.proxy)) {
        options.agent = new HttpsProxyAgent(npuHttpsProxy);
        console.log('use networkProxy:', npuHttpsProxy);
      }

      if (options.proxy.indexOf('http:') === 0 && npuHttpProxy && !this.isInNoProxyConfig(options.proxy)) {
        options.agent = new HttpProxyAgent(npuHttpProxy);
        console.log('use networkProxy:', npuHttpsProxy);
      }
    }

    if (typeof options.npu === 'string') {
      console.log('use networkProxy:', options.npu);
      if (options.proxy.indexOf('https') === 0) {
        options.agent = new HttpsProxyAgent(options.npu);
      } else if (options.proxy.indexOf('http') === 0) {
        options.agent = new HttpProxyAgent(options.npu);
      }
    }

    var proxy;
    if (options.agent) {
      proxy = httpProxy.createProxyServer({ agent: options.agent });
    } else {
      proxy = httpProxy.createProxyServer({});
    }
    before.push(function (req, res) {
      proxy.web(req, res, {
        target: options.proxy,
        changeOrigin: true
      });
    });
  }

  var serverOptions = {
    before: before,
    headers: this.headers,
    onError: function (err, req, res) {
      if (options.logFn) {
        options.logFn(req, res, err);
      }

      res.end();
    }
  };
  if (options.https) {
    serverOptions.https = options.https;
  }

  this.server = union.createServer(serverOptions);
}
968373
function subscribe() {
    console.log(' > ', 'init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123']);
    rpcClient.methodCall('init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123'], function (err, res) {
        console.log(err, res);
    });
}
61866
function JRPC(options) {
  this.active = true;
  this.transmitter = null;
  this.remoteTimeout = 60000;
  this.localTimeout = 0;
  this.serial = 0;
  this.outbox = {
    requests : [],
    responses: []
  };
  this.inbox = {};
  this.localTimers = {};
  this.outTimers = {};
  this.localComponents = {
    'system.listComponents'      : true,
    'system.extension.dual-batch': true
  };
  this.remoteComponents = {};
  this.exposed = {};

  this.exposed['system.listComponents'] = (function(params, next) {
    if (typeof params === 'object' && params !== null) {
      this.remoteComponents = params;
      this.remoteComponents['system._upgraded'] = true;
    }
    return next(null, this.localComponents);
  }).bind(this);

  this.exposed['system.extension.dual-batch'] = function(params, next) {
    return next(null, true);
  };

  if (typeof options === 'object') {
    if (
      'remoteTimeout' in options
      && typeof options['remoteTimeout'] === 'number'
    ) {
      this.remoteTimeout = options['remoteTimeout'] * 1000;
    }

    if (
      'localTimeout' in options
      && typeof options['localTimeout'] === 'number'
    ) {
      this.localTimeout = options['localTimeout'] * 1000;
    }
  }
}
189895
function(callback)
    {
        // Connect to the given URI with the given options
        self.mongo.MongoClient.connect(self.config.uri, defaultOpts, function(err, db) {

            if (err) {
                return callback && callback(err);
            }

            // Rewrite connection
            self.connection = db;

            callback && callback(null, db);
        });
    }
315613
function WebRequest (options, callback) {
    request(options, function (err, response, body) {
        if (err) {
            return callback(err);
        }

        callback(null, body);
    });
}
1034732
function RestClient(url, options) { // XXX what are the options?
  // call super
  Endpoint.call(this)

  /*****************************************************************************
   * @property {string} url -- xxx
   */
  this.url = url
  // setting this.client = this !!! this is so that child endpoint get
  // this.client set properly when calling end
  /*****************************************************************************
   * @property {xxx} client -- xxx
   */
  this.client = this
  /*****************************************************************************
   * @property {object} defaultOptions -- xxx
   */
  this.defaultOptions = options || {}

  // setup authenticator
  if ("authentication" in this.defaultOptions) {
    this._setupAuthentication(this.defaultOptions["authentication"])
  }

  // allow accessing "request" module from this client
  this.request = require("request")
}
324656
function Client(svc, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  // We have to suffix all client properties to be safe, since the message
  // names aren't prefixed with clients (unlike servers).
  this._svc$ = svc;
  this._channels$ = []; // Active channels.
  this._fns$ = []; // Middleware functions.

  this._buffering$ = !!opts.buffering;
  this._cache$ = opts.cache || {}; // For backwards compatibility.
  this._policy$ = opts.channelPolicy;
  this._strict$ = !!opts.strictTypes;
  this._timeout$ = utils.getOption(opts, 'timeout', 10000);

  if (opts.remoteProtocols) {
    insertRemoteProtocols(this._cache$, opts.remoteProtocols, svc, true);
  }

  this._svc$.messages.forEach(function (msg) {
    this[msg.name] = this._createMessageHandler$(msg);
  }, this);
}
611034
public static ClientHttpConnector create(ClientOptions options) {
		HttpClient httpClient = HttpClient.create();

		if (usingCustomCerts(options)) {
			TrustManagerFactory trustManagerFactory =
					sslCertificateUtils.createTrustManagerFactory(options.getCaCertFiles());

			httpClient = httpClient.secure(sslContextSpec -> sslContextSpec
					.sslContext(SslContextBuilder.forClient()
							.sslProvider(SslProvider.JDK)
							.trustManager(trustManagerFactory)));
		} else {
			httpClient = httpClient.secure(sslContextSpec -> sslContextSpec
					.sslContext(SslContextBuilder.forClient()
							.sslProvider(SslProvider.JDK)));
		}

		if (options.getConnectionTimeout() != null) {
			httpClient = httpClient.tcpConfiguration(tcpClient ->
					tcpClient.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
							Math.toIntExact(options.getConnectionTimeout().toMillis())));
		}

		return new ReactorClientHttpConnector(httpClient);
	}
1349952
function getHost(uri) {
  const uriObj = url.parse(uri);
  return `${uriObj.protocol}//${uriObj.host}`;
}
1072906
function TcpConnection(options) {
    this.options = util._extend({host: 'localhost', port: '80', localAddress: process.env.LOCAL_ADDRESS}, options);
    this._config = JSON.stringify(this.options);
    if (logger.isDebugEnabled()) {
        logger.debug('Created with %s', this._config);
    }
}
283695
private static function constructMongoClient($uri, $options)
    {
        if (isset($uri)) {
            if (isset($options)) {
                return new MongoClient($uri, $options);
            }
            return new MongoClient($uri);
        }
        return new MongoClient();
    }