...
 
Commits (7)
node-forever-agent (0.6.1-1) unstable; urgency=medium
* Team upload
* New upstream version 0.6.1
* Use salsa.debian.org in Vcs-* fields
* Bump debhelper compatibility level to 11
* Bump Standards-Version to 4.2.1 (no changes needed)
* Change section to javascript, priority to optional
-- Pirate Praveen <praveen@debian.org> Tue, 18 Sep 2018 20:54:49 +0530
node-forever-agent (0.5.1-1) unstable; urgency=low node-forever-agent (0.5.1-1) unstable; urgency=low
* Initial release (Closes: #719712) * Initial release (Closes: #719712)
......
Source: node-forever-agent Source: node-forever-agent
Section: web Section: javascript
Priority: extra Priority: optional
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org> Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Uploaders: Jérémy Lal <kapouer@melix.org> Uploaders: Jérémy Lal <kapouer@melix.org>
Build-Depends: Build-Depends:
debhelper (>= 8~) debhelper (>= 11~)
, dh-buildinfo , nodejs
Standards-Version: 3.9.4 Standards-Version: 4.2.1
Homepage: https://github.com/mikeal/forever-agent Homepage: https://github.com/mikeal/forever-agent
Vcs-Git: git://anonscm.debian.org/collab-maint/node-forever-agent.git Vcs-Git: https://salsa.debian.org/js-team/node-forever-agent.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/node-forever-agent.git Vcs-Browser: https://salsa.debian.org/js-team/node-forever-agent
Package: node-forever-agent Package: node-forever-agent
Architecture: all Architecture: all
......
...@@ -6,6 +6,17 @@ var util = require('util') ...@@ -6,6 +6,17 @@ var util = require('util')
, net = require('net') , net = require('net')
, tls = require('tls') , tls = require('tls')
, AgentSSL = require('https').Agent , 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
}
function ForeverAgent(options) { function ForeverAgent(options) {
var self = this var self = this
...@@ -16,7 +27,8 @@ function ForeverAgent(options) { ...@@ -16,7 +27,8 @@ function ForeverAgent(options) {
self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets
self.minSockets = self.options.minSockets || ForeverAgent.defaultMinSockets self.minSockets = self.options.minSockets || ForeverAgent.defaultMinSockets
self.on('free', function(socket, host, port) { self.on('free', function(socket, host, port) {
var name = host + ':' + port var name = getConnectionName(host, port)
if (self.requests[name] && self.requests[name].length) { if (self.requests[name] && self.requests[name].length) {
self.requests[name].shift().onSocket(socket) self.requests[name].shift().onSocket(socket)
} else if (self.sockets[name].length < self.minSockets) { } else if (self.sockets[name].length < self.minSockets) {
...@@ -24,7 +36,7 @@ function ForeverAgent(options) { ...@@ -24,7 +36,7 @@ function ForeverAgent(options) {
self.freeSockets[name].push(socket) self.freeSockets[name].push(socket)
// if an error happens while we don't use the socket anyway, meh, throw the socket away // if an error happens while we don't use the socket anyway, meh, throw the socket away
function onIdleError() { var onIdleError = function() {
socket.destroy() socket.destroy()
} }
socket._onIdleError = onIdleError socket._onIdleError = onIdleError
...@@ -47,7 +59,14 @@ ForeverAgent.defaultMinSockets = 5 ...@@ -47,7 +59,14 @@ ForeverAgent.defaultMinSockets = 5
ForeverAgent.prototype.createConnection = net.createConnection ForeverAgent.prototype.createConnection = net.createConnection
ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest
ForeverAgent.prototype.addRequest = function(req, host, port) { ForeverAgent.prototype.addRequest = function(req, host, port) {
var name = host + ':' + port var name = getConnectionName(host, port)
if (typeof host !== 'string') {
var options = host
port = options.port
host = options.host
}
if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) { if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) {
var idleSocket = this.freeSockets[name].pop() var idleSocket = this.freeSockets[name].pop()
idleSocket.removeListener('error', idleSocket._onIdleError) idleSocket.removeListener('error', idleSocket._onIdleError)
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (http://www.futurealoof.com)", "author": "Mikeal Rogers <mikeal.rogers@gmail.com> (http://www.futurealoof.com)",
"name": "forever-agent", "name": "forever-agent",
"description": "HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.", "description": "HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.",
"version": "0.5.1", "version": "0.6.1",
"license": "Apache-2.0",
"repository": { "repository": {
"url": "https://github.com/mikeal/forever-agent" "url": "https://github.com/mikeal/forever-agent"
}, },
......