mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
http: agent takes options instead of host, port pair
This commit is contained in:
parent
0da96cca59
commit
2b03ba5917
12
lib/http.js
12
lib/http.js
@ -959,10 +959,10 @@ function connectionListener(socket) {
|
||||
exports._connectionListener = connectionListener;
|
||||
|
||||
|
||||
|
||||
function Agent(host, port) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
function Agent(options) {
|
||||
this.options = options;
|
||||
this.host = options.host;
|
||||
this.port = options.port;
|
||||
|
||||
this.queue = [];
|
||||
this.sockets = [];
|
||||
@ -1228,7 +1228,7 @@ function getAgent(host, port) {
|
||||
var agent = agents[id];
|
||||
|
||||
if (!agent) {
|
||||
agent = agents[id] = new Agent(host, port);
|
||||
agent = agents[id] = new Agent({ host: host, port: port });
|
||||
}
|
||||
|
||||
return agent;
|
||||
@ -1248,7 +1248,7 @@ exports.request = function(options, cb) {
|
||||
if (options.agent === undefined) {
|
||||
options.agent = getAgent(options.host, options.port);
|
||||
} else if (options.agent === false) {
|
||||
options.agent = new Agent(options.host, options.port);
|
||||
options.agent = new Agent(options);
|
||||
}
|
||||
return exports._requestFromAgent(options, cb);
|
||||
};
|
||||
|
@ -26,9 +26,7 @@ exports.createServer = function(opts, requestListener) {
|
||||
var agents = {};
|
||||
|
||||
function Agent(options) {
|
||||
http.Agent.call(this, options.host, options.port);
|
||||
|
||||
this.options = options;
|
||||
http.Agent.call(this, options);
|
||||
}
|
||||
inherits(Agent, http.Agent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user