http: agent takes options instead of host, port pair

This commit is contained in:
Mikeal Rogers 2011-02-05 02:35:25 -08:00 committed by Ryan Dahl
parent 0da96cca59
commit 2b03ba5917
2 changed files with 7 additions and 9 deletions

View File

@ -959,10 +959,10 @@ function connectionListener(socket) {
exports._connectionListener = connectionListener; exports._connectionListener = connectionListener;
function Agent(options) {
function Agent(host, port) { this.options = options;
this.host = host; this.host = options.host;
this.port = port; this.port = options.port;
this.queue = []; this.queue = [];
this.sockets = []; this.sockets = [];
@ -1228,7 +1228,7 @@ function getAgent(host, port) {
var agent = agents[id]; var agent = agents[id];
if (!agent) { if (!agent) {
agent = agents[id] = new Agent(host, port); agent = agents[id] = new Agent({ host: host, port: port });
} }
return agent; return agent;
@ -1248,7 +1248,7 @@ exports.request = function(options, cb) {
if (options.agent === undefined) { if (options.agent === undefined) {
options.agent = getAgent(options.host, options.port); options.agent = getAgent(options.host, options.port);
} else if (options.agent === false) { } else if (options.agent === false) {
options.agent = new Agent(options.host, options.port); options.agent = new Agent(options);
} }
return exports._requestFromAgent(options, cb); return exports._requestFromAgent(options, cb);
}; };

View File

@ -26,9 +26,7 @@ exports.createServer = function(opts, requestListener) {
var agents = {}; var agents = {};
function Agent(options) { function Agent(options) {
http.Agent.call(this, options.host, options.port); http.Agent.call(this, options);
this.options = options;
} }
inherits(Agent, http.Agent); inherits(Agent, http.Agent);