Don't invoke the `agent.requst()` or `agent.get()` functions
directly. Instead, use the public API and pass the agent
instance in as the `agent` option.
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 5,
- maxFreeSockets: 5,
+ maxFreeSockets: 5
});
var server = http.createServer(function (req, res) {
});
function get(path, callback) {
- return agent.get({
+ return http.get({
host: 'localhost',
port: common.PORT,
+ agent: agent,
path: path
}, callback);
}
// then 10 more when they all finish.
function makeReqs(n, cb) {
for (var i = 0; i < n; i++)
- makeReq(i, then)
+ makeReq(i, then);
function then(er) {
if (er)
}
function makeReq(i, cb) {
- agent.request({ port: common.PORT, path: '/' + i }, function(res) {
+ http.request({
+ port: common.PORT,
+ path: '/' + i,
+ agent: agent
+ }, function(res) {
var data = '';
res.setEncoding('ascii');
res.on('data', function(c) {
return;
}
- var req = agent.request({
+ var req = http.request({
port: common.PORT,
- path: '/' + n
+ path: '/' + n,
+ agent: agent
});
req.end();