|
|
@ -1174,16 +1174,21 @@ function getAgent(host, port) { |
|
|
|
exports.getAgent = getAgent; |
|
|
|
|
|
|
|
|
|
|
|
exports._requestFromAgent = function(agent, options, cb) { |
|
|
|
var req = agent.appendMessage(options); |
|
|
|
exports._requestFromAgent = function(options, cb) { |
|
|
|
var req = options.agent.appendMessage(options); |
|
|
|
req.agent = options.agent; |
|
|
|
if (cb) req.once('response', cb); |
|
|
|
return req; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
exports.request = function(options, cb) { |
|
|
|
var agent = getAgent(options.host, options.port); |
|
|
|
return exports._requestFromAgent(agent, 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); |
|
|
|
} |
|
|
|
return exports._requestFromAgent(options, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|