proxy-agent
Advanced tools
Comparing version 2.1.0 to 2.2.0
2.2.0 / 2018-01-15 | ||
================== | ||
* Add `auth` to proxyUri | ||
* Upgrade to "agent-base" v4.2.0 | ||
* Use `Object.keys()` to determine the supported proxies | ||
* Remove `extend` dependency | ||
* Update dependencies | ||
2.1.0 / 2017-07-20 | ||
@@ -3,0 +12,0 @@ ================== |
36
index.js
@@ -9,3 +9,2 @@ 'use strict'; | ||
var LRU = require('lru-cache'); | ||
var extend = require('extend'); | ||
var Agent = require('agent-base'); | ||
@@ -90,3 +89,3 @@ var inherits = require('util').inherits; | ||
if (opts.proxies) { | ||
proxies = extend(Object.create(exports.proxies), opts.proxies); | ||
proxies = Object.assign({}, exports.proxies, opts.proxies); | ||
} else { | ||
@@ -100,3 +99,3 @@ proxies = exports.proxies; | ||
throw new TypeError('You must specify a "protocol" for the ' + | ||
'proxy type (' + types().join(', ') + ')'); | ||
'proxy type (' + Object.keys(proxies).join(', ') + ')'); | ||
} | ||
@@ -117,7 +116,8 @@ | ||
// format the proxy info back into a URI, since an opts object | ||
// could have been passed in originally. This generated URI is used | ||
// as part of the "key" for the LRU cache | ||
// could have been passed in originally. This generated URI is | ||
// used as part of the "key" for the LRU cache | ||
this.proxyUri = url.format({ | ||
protocol: protocol + ':', | ||
slashes: true, | ||
auth:opts.auth, | ||
hostname: opts.hostname || opts.host, | ||
@@ -134,3 +134,3 @@ port: opts.port | ||
function connect (req, opts, fn) { | ||
function connect (req, opts) { | ||
// create the "key" for the LRU cache | ||
@@ -145,3 +145,5 @@ var key = this.proxyUri; | ||
agent = this.proxyFn(this.proxy, opts.secureEndpoint); | ||
if (agent) exports.cache.set(key, agent); | ||
if (agent) { | ||
exports.cache.set(key, agent); | ||
} | ||
} else { | ||
@@ -151,21 +153,3 @@ debug('cache hit with key: %o', key); | ||
// XXX: agent.callback() is an agent-base-ism | ||
// TODO: add support for generic `http.Agent` instances by calling | ||
// agent.addRequest(), but with support for <= 0.10.x and >= 0.12.x | ||
agent.callback(req, opts, fn); | ||
return agent; | ||
} | ||
/** | ||
* Returns an Array of supported protocol string names. | ||
* | ||
* @return {Array} | ||
* @api private | ||
*/ | ||
function types () { | ||
var rtn = []; | ||
// not using Object.keys() so that we get any | ||
// potential prototype values as well | ||
for (var type in exports.proxies) rtn.push(type); | ||
return rtn; | ||
} |
{ | ||
"name": "proxy-agent", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Maps proxy protocols to `http.Agent` implementations", | ||
@@ -29,13 +29,12 @@ "main": "index.js", | ||
"dependencies": { | ||
"agent-base": "2", | ||
"debug": "2", | ||
"extend": "3", | ||
"http-proxy-agent": "1", | ||
"https-proxy-agent": "1", | ||
"lru-cache": "~2.6.5", | ||
"agent-base": "^4.2.0", | ||
"debug": "^2.6.8", | ||
"http-proxy-agent": "^1.0.0", | ||
"https-proxy-agent": "^1.0.0", | ||
"lru-cache": "^2.6.5", | ||
"pac-proxy-agent": "^2.0.0", | ||
"socks-proxy-agent": "2" | ||
"socks-proxy-agent": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "2", | ||
"mocha": "^3.4.2", | ||
"proxy": "0.2.3", | ||
@@ -42,0 +41,0 @@ "socksv5": "0.0.6", |
7
21130
8
386
+ Addedlru-cache@2.7.3(transitive)
- Removedextend@3
- Removedlru-cache@2.6.5(transitive)
- Removedsocks-proxy-agent@2.1.1(transitive)
Updatedagent-base@^4.2.0
Updateddebug@^2.6.8
Updatedhttp-proxy-agent@^1.0.0
Updatedhttps-proxy-agent@^1.0.0
Updatedlru-cache@^2.6.5
Updatedsocks-proxy-agent@^3.0.0