How to use agent-base - 10 common examples

To help you get started, we’ve selected a few agent-base 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 TooTallNate / node-http-proxy-agent / index.js View on Github external
function HttpProxyAgent(opts) {
	if (!(this instanceof HttpProxyAgent)) return new HttpProxyAgent(opts);
	if ('string' == typeof opts) opts = url.parse(opts);
	if (!opts)
		throw new Error(
			'an HTTP(S) proxy server `host` and `port` must be specified!'
		);
	debug('creating new HttpProxyAgent instance: %o', opts);
	Agent.call(this, opts);

	var proxy = Object.assign({}, opts);

	// if `true`, then connect to the proxy server over TLS. defaults to `false`.
	this.secureProxy = proxy.protocol
		? /^https:?$/i.test(proxy.protocol)
		: false;

	// prefer `hostname` over `host`, and set the `port` if needed
	proxy.host = proxy.hostname || proxy.host;
	proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

	if (proxy.host && proxy.path) {
		// if both a `host` and `path` are specified then it's most likely the
		// result of a `url.parse()` call... we need to remove the `path` portion so
		// that `net.connect()` doesn't attempt to open that as a unix socket file.
github expo / expo-github-action / node_modules / https-proxy-agent / index.js View on Github external
function HttpsProxyAgent(opts) {
	if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
	if ('string' == typeof opts) opts = url.parse(opts);
	if (!opts)
		throw new Error(
			'an HTTP(S) proxy server `host` and `port` must be specified!'
		);
	debug('creating new HttpsProxyAgent instance: %o', opts);
	Agent.call(this, opts);

	var proxy = Object.assign({}, opts);

	// if `true`, then connect to the proxy server over TLS. defaults to `false`.
	this.secureProxy = proxy.protocol
		? /^https:?$/i.test(proxy.protocol)
		: false;

	// prefer `hostname` over `host`, and set the `port` if needed
	proxy.host = proxy.hostname || proxy.host;
	proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

	// ALPN is supported by Node.js >= v5.
	// attempt to negotiate http/1.1 for proxy servers that support http/2
	if (this.secureProxy && !('ALPNProtocols' in proxy)) {
		proxy.ALPNProtocols = ['http 1.1'];
github qiushi123 / xiaochengxu_demos / 014云开发实现小程序支付 / cloud / pay / node_modules / http-proxy-agent / index.js View on Github external
function HttpProxyAgent(opts) {
    if (!(this instanceof HttpProxyAgent)) return new HttpProxyAgent(opts);
    if ('string' == typeof opts) opts = url.parse(opts);
    if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
    debug('creating new HttpProxyAgent instance: %o', opts);
    Agent.call(this, opts);

    var proxy = Object.assign({}, opts);

    // if `true`, then connect to the proxy server over TLS. defaults to `false`.
    this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;

    // prefer `hostname` over `host`, and set the `port` if needed
    proxy.host = proxy.hostname || proxy.host;
    proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

    if (proxy.host && proxy.path) {
        // if both a `host` and `path` are specified then it's most likely the
        // result of a `url.parse()` call... we need to remove the `path` portion so
        // that `net.connect()` doesn't attempt to open that as a unix socket file.
        delete proxy.path;
        delete proxy.pathname;
github snowflakedb / snowflake-connector-nodejs / lib / agent / https_proxy_ocsp_agent.js View on Github external
function HttpsProxyAgent(opts)
{
  if (!(this instanceof HttpsProxyAgent))
  {
    return new HttpsProxyAgent(opts);
  }
  if ('string' == typeof opts)
  {
    opts = url.parse(opts);
  }
  if (!opts)
  {
    throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
  }
  debug('creating new HttpsProxyAgent instance: %o', opts);
  Agent.call(this, connect);

  var proxy = extend({}, opts);

  // if `true`, then connect to the proxy server over TLS. defaults to `false`.
  this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;

  // prefer `hostname` over `host`, and set the `port` if needed
  proxy.host = proxy.hostname || proxy.host;
  proxy.port = proxy.port || (this.secureProxy ? 443 : 80);

  if (proxy.host && proxy.path)
  {
    // if both a `host` and `path` are specified then it's most likely the
    // result of a `url.parse()` call... we need to remove the `path` portion so
    // that `net.connect()` doesn't attempt to open that as a unix socket file.
    delete proxy.path;
github TooTallNate / node-https-proxy-agent / index.js View on Github external
function HttpsProxyAgent(opts) {
	if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
	if ('string' == typeof opts) opts = url.parse(opts);
	if (!opts)
		throw new Error(
			'an HTTP(S) proxy server `host` and `port` must be specified!'
		);
	debug('creating new HttpsProxyAgent instance: %o', opts);
	Agent.call(this, opts);

	var proxy = Object.assign({}, opts);

	// if `true`, then connect to the proxy server over TLS. defaults to `false`.
	this.secureProxy = proxy.protocol
		? /^https:?$/i.test(proxy.protocol)
		: false;

	// prefer `hostname` over `host`, and set the `port` if needed
	proxy.host = proxy.hostname || proxy.host;
	proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

	// ALPN is supported by Node.js >= v5.
	// attempt to negotiate http/1.1 for proxy servers that support http/2
	if (this.secureProxy && !('ALPNProtocols' in proxy)) {
		proxy.ALPNProtocols = ['http 1.1'];
github fossasia / susper.com / node_modules / https-proxy-agent / index.js View on Github external
function HttpsProxyAgent(opts) {
  if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
  if ('string' == typeof opts) opts = url.parse(opts);
  if (!opts)
    throw new Error(
      'an HTTP(S) proxy server `host` and `port` must be specified!'
    );
  debug('creating new HttpsProxyAgent instance: %o', opts);
  Agent.call(this, opts);

  var proxy = Object.assign({}, opts);

  // if `true`, then connect to the proxy server over TLS. defaults to `false`.
  this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;

  // prefer `hostname` over `host`, and set the `port` if needed
  proxy.host = proxy.hostname || proxy.host;
  proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

  // ALPN is supported by Node.js >= v5.
  // attempt to negotiate http/1.1 for proxy servers that support http/2
  if (this.secureProxy && !('ALPNProtocols' in proxy)) {
    proxy.ALPNProtocols = ['http 1.1']
  }
github circonus-labs / nad / node_modules / circonusapi2 / node_modules / https-proxy-agent / https-proxy-agent.js View on Github external
function HttpsProxyAgent (opts) {
  if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
  if ('string' == typeof opts) opts = url.parse(opts);
  if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
  debug('creating new HttpsProxyAgent instance: %o', opts);
  Agent.call(this, connect);

  var proxy = extend({}, opts);

  // if `true`, then connect to the proxy server over TLS. defaults to `false`.
  this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;

  // prefer `hostname` over `host`, and set the `port` if needed
  proxy.host = proxy.hostname || proxy.host;
  proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);

  if (proxy.host && proxy.path) {
    // if both a `host` and `path` are specified then it's most likely the
    // result of a `url.parse()` call... we need to remove the `path` portion so
    // that `net.connect()` doesn't attempt to open that as a unix socket file.
    delete proxy.path;
    delete proxy.pathname;
github TooTallNate / node-pac-proxy-agent / index.js View on Github external
if (opts.href) {
      if (opts.path && !opts.pathname) {
        opts.pathname = opts.path;
      }
      opts.slashes = true;
      uri = format(opts);
    } else {
      uri = opts.uri;
    }
  }
  if (!opts) opts = {};

  if (!uri) throw new Error('a PAC file URI must be specified!');
  debug('creating PacProxyAgent with URI %o and options %o', uri, opts);

  Agent.call(this, connect);

  // strip the "pac+" prefix
  this.uri = uri.replace(/^pac\+/i, '');

  this.sandbox = opts.sandbox;

  this.proxy = opts;

  this.cache = this._resolver = null;
}
inherits(PacProxyAgent, Agent);
github TooTallNate / node-socks-proxy-agent / index.js View on Github external
function SocksProxyAgent(opts) {
	if (!(this instanceof SocksProxyAgent)) return new SocksProxyAgent(opts);
	if ('string' == typeof opts) opts = url.parse(opts);
	if (!opts)
		throw new Error(
			'a SOCKS proxy server `host` and `port` must be specified!'
		);
	Agent.call(this, opts);

	var proxy = Object.assign({}, opts);

	// prefer `hostname` over `host`, because of `url.parse()`
	proxy.host = proxy.hostname || proxy.host;

	// SOCKS doesn't *technically* have a default port, but this is
	// the same default that `curl(1)` uses
	proxy.port = +proxy.port || 1080;

	if (proxy.host && proxy.path) {
		// if both a `host` and `path` are specified then it's most likely the
		// result of a `url.parse()` call... we need to remove the `path` portion so
		// that `net.connect()` doesn't attempt to open that as a unix socket file.
		delete proxy.path;
		delete proxy.pathname;
github qiushi123 / xiaochengxu_demos / 014云开发实现小程序支付 / cloud / pay / node_modules / pac-proxy-agent / index.js View on Github external
if (opts.href) {
            if (opts.path && !opts.pathname) {
                opts.pathname = opts.path;
            }
            opts.slashes = true;
            uri = format(opts);
        } else {
            uri = opts.uri;
        }
    }
    if (!opts) opts = {};

    if (!uri) throw new Error('a PAC file URI must be specified!');
    debug('creating PacProxyAgent with URI %o and options %o', uri, opts);

    Agent.call(this, connect);

    // strip the "pac+" prefix
    this.uri = uri.replace(/^pac\+/i, '');

    this.sandbox = opts.sandbox;

    this.proxy = opts;

    this.cache = this._resolver = null;
}

agent-base

Turn a function into an `http.Agent` instance

MIT
Latest version published 8 months ago

Package Health Score

84 / 100
Full package analysis

Popular agent-base functions