test: update "http-*" tests to only use public API
authorNathan Rajlich <nathan@tootallnate.net>
Tue, 25 Feb 2014 22:18:43 +0000 (14:18 -0800)
committerNathan Rajlich <nathan@tootallnate.net>
Wed, 26 Feb 2014 21:19:06 +0000 (13:19 -0800)
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.

test/simple/test-http-agent-keepalive.js
test/simple/test-http-keepalive-maxsockets.js
test/simple/test-http-keepalive-request.js

index 79722a0..f56027a 100644 (file)
@@ -29,7 +29,7 @@ var agent = new Agent({
   keepAlive: true,
   keepAliveMsecs: 1000,
   maxSockets: 5,
-  maxFreeSockets: 5,
+  maxFreeSockets: 5
 });
 
 var server = http.createServer(function (req, res) {
@@ -47,9 +47,10 @@ 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);
 }
index c3ca548..8481eec 100644 (file)
@@ -44,7 +44,7 @@ var agent = http.Agent({
 // 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)
@@ -55,7 +55,11 @@ function makeReqs(n, cb) {
 }
 
 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) {
index 1178dca..3b87375 100644 (file)
@@ -54,9 +54,10 @@ function makeRequest(n) {
     return;
   }
 
-  var req = agent.request({
+  var req = http.request({
     port: common.PORT,
-    path: '/' + n
+    path: '/' + n,
+    agent: agent
   });
 
   req.end();