Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 2b03ba5

Browse files
mikealry
authored andcommitted
http: agent takes options instead of host, port pair
1 parent 0da96cc commit 2b03ba5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/http.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,10 @@ function connectionListener(socket) {
959959
exports._connectionListener = connectionListener;
960960

961961

962-
963-
function Agent(host, port) {
964-
this.host = host;
965-
this.port = port;
962+
function Agent(options) {
963+
this.options = options;
964+
this.host = options.host;
965+
this.port = options.port;
966966

967967
this.queue = [];
968968
this.sockets = [];
@@ -1228,7 +1228,7 @@ function getAgent(host, port) {
12281228
var agent = agents[id];
12291229

12301230
if (!agent) {
1231-
agent = agents[id] = new Agent(host, port);
1231+
agent = agents[id] = new Agent({ host: host, port: port });
12321232
}
12331233

12341234
return agent;
@@ -1248,7 +1248,7 @@ exports.request = function(options, cb) {
12481248
if (options.agent === undefined) {
12491249
options.agent = getAgent(options.host, options.port);
12501250
} else if (options.agent === false) {
1251-
options.agent = new Agent(options.host, options.port);
1251+
options.agent = new Agent(options);
12521252
}
12531253
return exports._requestFromAgent(options, cb);
12541254
};

lib/https.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ exports.createServer = function(opts, requestListener) {
2626
var agents = {};
2727

2828
function Agent(options) {
29-
http.Agent.call(this, options.host, options.port);
30-
31-
this.options = options;
29+
http.Agent.call(this, options);
3230
}
3331
inherits(Agent, http.Agent);
3432

0 commit comments

Comments
 (0)