forever-agent
Advanced tools
Comparing version 0.6.0 to 0.6.1
17
index.js
@@ -9,2 +9,13 @@ module.exports = ForeverAgent | ||
, AgentSSL = require('https').Agent | ||
function getConnectionName(host, port) { | ||
var name = '' | ||
if (typeof host === 'string') { | ||
name = host + ':' + port | ||
} else { | ||
// For node.js v012.0 and iojs-v1.5.1, host is an object. And any existing localAddress is part of the connection name. | ||
name = host.host + ':' + host.port + ':' + (host.localAddress ? (host.localAddress + ':') : ':') | ||
} | ||
return name | ||
} | ||
@@ -20,3 +31,4 @@ function ForeverAgent(options) { | ||
self.on('free', function(socket, host, port) { | ||
var name = host + ':' + port | ||
var name = getConnectionName(host, port) | ||
if (self.requests[name] && self.requests[name].length) { | ||
@@ -52,2 +64,4 @@ self.requests[name].shift().onSocket(socket) | ||
ForeverAgent.prototype.addRequest = function(req, host, port) { | ||
var name = getConnectionName(host, port) | ||
if (typeof host !== 'string') { | ||
@@ -59,3 +73,2 @@ var options = host | ||
var name = host + ':' + port | ||
if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) { | ||
@@ -62,0 +75,0 @@ var idleSocket = this.freeSockets[name].pop() |
@@ -5,3 +5,3 @@ { | ||
"description": "HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "repository": { |
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
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
14007
118