self._agent = new http.Agent();
constructor(s3Endpoint, s3Auth, sourceHTTPAgent) { super(); this._s3Endpoint = s3Endpoint; this._s3Auth = s3Auth; // TODO: For SSL support, create HTTPS agents instead. this._sourceHTTPAgent = sourceHTTPAgent || new http.Agent({ keepAlive: true }); this._setupVaultclientCache(); }
// NOTE: A rewrite occurred in 0.11 that changed the addRequest signature // from (req, host, port, localAddress) to (req, options) // Here, I use the longer signature to maintain 0.10 support, even though // the rest of the arguments aren't actually used wrap(http.Agent.prototype, 'addRequest', function (original) { return function (req) { var onSocket = req.onSocket req.onSocket = ins.bindFunction(function (socket) { patchOnRead(socket) return onSocket.apply(this, arguments) }) return original.apply(this, arguments) } })
constructor (config = {}) { if (config.host !== undefined && (!config.host || typeof config.host !== 'string')) { throw new Error('Config host must be a string with value'); } if (config.port !== undefined && (config.port < 1 || parseInt(config.port, 10) !== config.port)) { throw new Error('Config port must be positive numeric integer'); } if (config.timeout !== undefined && (config.timeout < 1 || parseInt(config.timeout, 10) !== config.timeout)) { throw new Error('Config timeout must be positive numeric integer'); } this.settings = Object.assign({}, defaults, config); if (this.settings.keepAlive) { this.agent = new http.Agent({keepAlive: true}); } }
/** * Return an S3 client instance using the given account credentials. * @param {Object} accountCreds - Object containing account credentials * @param {String} accountCreds.accessKeyId - The account access key * @param {String} accountCreds.secretAccessKey - The account secret key * @return {AWS.S3} The S3 client instance to make requests with */ _getS3Client(accountCreds) { return new AWS.S3({ endpoint: this._s3Endpoint, credentials: { accessKeyId: accountCreds.accessKeyId, secretAccessKey: accountCreds.secretAccessKey, }, sslEnabled: this._transport === 'https', s3ForcePathStyle: true, signatureVersion: 'v4', httpOptions: { agent: new http.Agent({ keepAlive: true }), timeout: 0, }, maxRetries: 0, }); }
/** * An HTTP Agent for proxying requests through Tor using SOCKS5. * * @param {object} opts */ function TorAgent(opts) { if (!(this instanceof TorAgent)) { return new TorAgent(); } http.Agent.call(this, opts); this.socksHost = opts.socksHost || 'localhost'; this.socksPort = opts.socksPort || 9050; this.defaultPort = 80; // Used when invoking TorAgent.create this.tor = opts.tor; // Prevent protocol check, wrap destroy this.protocol = null; this.defaultDestroy = this.destroy; this.destroy = this.destroyWrapper; }
/** * Helper method to create a new HTTP(S) agent * @param {string} protocol - "https" || "http" * @return {http.Agent|https.Agent} new http or https Agent */ _createHTTPAgent(protocol) { const params = { keepAlive: true }; if (protocol === 'https') { return new https.Agent(params); } return new http.Agent(params); }
this._isActive = false; this._httpAgent = new http.Agent({ keepAlive: true }); this._logger = new Logger('Backbeat:GC');
this.httpAgent = new http.Agent({ keepAlive: true });
this.sourceHTTPAgent = new https.Agent({ key: internalHttpsConfig.key, cert: internalHttpsConfig.cert, }); } else { this.sourceHTTPAgent = new http.Agent({ keepAlive: true }); this.destHTTPAgent = new https.Agent({ key: httpsConfig.key, cert: httpsConfig.cert, }); } else { this.destHTTPAgent = new http.Agent({ keepAlive: true });
constructor(){ super(...arguments); this.Agent = http.Agent; this.globalAgent = http.globalAgent; this.enforceProtocol = 'http:'; }