https-proxied
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -9,22 +9,12 @@ var tls = require('tls'), | ||
var agents = {}; | ||
var parsers = http.parsers; | ||
function Agent(options) { | ||
http.Agent.call(this, options); | ||
} | ||
inherits(Agent, http.Agent); | ||
Agent.prototype.defaultPort = 443; | ||
Agent.prototype._getConnection = function(host, port, cb) { | ||
function createConnection(port, host, options) { | ||
var s; | ||
cb = cb || function() {}; | ||
if (this.options.proxy) { | ||
s = clearTextSocket(host, port, this.options, cb); | ||
if (options.proxy) { | ||
s = clearTextSocket(port, host, options); | ||
} | ||
else { | ||
s = tls.connect(port, host, this.options, cb); | ||
s = tls.connect(port, host, options); | ||
} | ||
@@ -35,5 +25,14 @@ | ||
function Agent(options) { | ||
http.Agent.call(this, options); | ||
this.createConnection = createConnection; | ||
} | ||
inherits(Agent, http.Agent); | ||
Agent.prototype.defaultPort = 443; | ||
var Connection = process.binding('crypto').Connection | ||
function clearTextSocket(host, port, options, cb) { | ||
function clearTextSocket(port, host, options) { | ||
var sslcontext = crypto.createCredentials({}); | ||
@@ -54,6 +53,3 @@ var pair = tls.createSecurePair(sslcontext, false); | ||
pair._doneFlag = false; | ||
pair.cycle(); | ||
pair.on('secure', function() { | ||
if (cb) cb(); | ||
}); | ||
pair.cycle(); | ||
}); | ||
@@ -141,24 +137,18 @@ | ||
function getAgent(options) { | ||
if (!options.port) options.port = 443; | ||
var globalAgent = new Agent(); | ||
var id = options.host + ':' + options.port; | ||
var agent = agents[id]; | ||
exports.globalAgent = globalAgent; | ||
exports.Agent = Agent; | ||
if (!agent) { | ||
agent = agents[id] = new Agent(options); | ||
exports.request = function(options, cb) { | ||
if (options.protocol && options.protocol !== 'https:') { | ||
throw new Error('Protocol:' + options.protocol + ' not supported.'); | ||
} | ||
return agent; | ||
} | ||
exports.getAgent = getAgent; | ||
exports.Agent = Agent; | ||
exports.request = function(options, cb) { | ||
if (options.agent === undefined) { | ||
options.agent = getAgent(options); | ||
} else if (options.agent === false) { | ||
options.agent = new Agent(options); | ||
options.agent = globalAgent; | ||
} | ||
return http._requestFromAgent(options, cb); | ||
options.createConnection = createConnection; | ||
options.defaultPort = options.defaultPort || 443; | ||
return new http.ClientRequest(options, cb); | ||
}; | ||
@@ -165,0 +155,0 @@ |
{ | ||
"name": "https-proxied", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A https client that works with SSL proxies", | ||
"engines": { "node": ">=0.4.0" }, | ||
"engines": { "node": ">=0.6.0" }, | ||
"author": "Vinay Pulim <v@pulim.com>", | ||
@@ -7,0 +7,0 @@ "repository" : { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
0
13623
183
5