summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-05-15 14:24:08 -0700
committerisaacs <i@izs.me>2013-07-09 22:31:11 -0700
commit6176e49181fcf81eb22919e2880b503d3f70e738 (patch)
tree57647d11466d808fc6786860c767e710bef4c974
parent48e159faf2f9cc952474a99e6146ae2486c28115 (diff)
downloadnode-6176e49181fcf81eb22919e2880b503d3f70e738.tar.gz
http: style
-rw-r--r--lib/_http_agent.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/_http_agent.js b/lib/_http_agent.js
index 7ad5c7ec5..c6983b779 100644
--- a/lib/_http_agent.js
+++ b/lib/_http_agent.js
@@ -66,6 +66,7 @@ function Agent(options) {
});
self.createConnection = net.createConnection;
}
+
util.inherits(Agent, EventEmitter);
exports.Agent = Agent;
@@ -91,6 +92,7 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
this.requests[name].push(req);
}
};
+
Agent.prototype.createSocket = function(name, host, port, localAddress, req) {
var self = this;
var options = util._extend({}, self.options);
@@ -111,18 +113,21 @@ Agent.prototype.createSocket = function(name, host, port, localAddress, req) {
self.sockets[name] = [];
}
this.sockets[name].push(s);
- var onFree = function() {
+
+ function onFree() {
self.emit('free', s, host, port, localAddress);
}
s.on('free', onFree);
- var onClose = function(err) {
+
+ function onClose(err) {
// This is the only place where sockets get removed from the Agent.
// If you want to remove a socket from the pool, just close it.
// All socket errors end in a close event anyway.
self.removeSocket(s, name, host, port, localAddress);
}
s.on('close', onClose);
- var onRemove = function() {
+
+ function onRemove() {
// We need this function for cases like HTTP 'upgrade'
// (defined by WebSockets) where we need to remove a socket from the pool
// because it'll be locked up indefinitely
@@ -134,6 +139,7 @@ Agent.prototype.createSocket = function(name, host, port, localAddress, req) {
s.on('agentRemove', onRemove);
return s;
};
+
Agent.prototype.removeSocket = function(s, name, host, port, localAddress) {
if (this.sockets[name]) {
var index = this.sockets[name].indexOf(s);