Expose agent in http and https client.
This commit is contained in:
parent
7892918353
commit
8d37f80f4b
13
lib/http.js
13
lib/http.js
@ -1174,16 +1174,21 @@ function getAgent(host, port) {
|
|||||||
exports.getAgent = getAgent;
|
exports.getAgent = getAgent;
|
||||||
|
|
||||||
|
|
||||||
exports._requestFromAgent = function(agent, options, cb) {
|
exports._requestFromAgent = function(options, cb) {
|
||||||
var req = agent.appendMessage(options);
|
var req = options.agent.appendMessage(options);
|
||||||
|
req.agent = options.agent;
|
||||||
if (cb) req.once('response', cb);
|
if (cb) req.once('response', cb);
|
||||||
return req;
|
return req;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.request = function(options, cb) {
|
exports.request = function(options, cb) {
|
||||||
var agent = getAgent(options.host, options.port);
|
if (options.agent === undefined) {
|
||||||
return exports._requestFromAgent(agent, options, cb);
|
options.agent = getAgent(options.host, options.port);
|
||||||
|
} else if (options.agent === false) {
|
||||||
|
options.agent = new Agent(options.host, options.port);
|
||||||
|
}
|
||||||
|
return exports._requestFromAgent(options, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,8 +59,12 @@ exports.getAgent = getAgent;
|
|||||||
|
|
||||||
|
|
||||||
exports.request = function(options, cb) {
|
exports.request = function(options, cb) {
|
||||||
var agent = getAgent(options);
|
if (options.agent === undefined) {
|
||||||
return http._requestFromAgent(agent, options, cb);
|
options.agent = getAgent(options);
|
||||||
|
} else if (options.agent === false) {
|
||||||
|
options.agent = new Agent(options);
|
||||||
|
}
|
||||||
|
return http._requestFromAgent(options, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user