Browse Source

test: update "http-*" tests to only use public API

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.
v0.11.12-release
Nathan Rajlich 11 years ago
parent
commit
0a5d8ca197
  1. 5
      test/simple/test-http-agent-keepalive.js
  2. 8
      test/simple/test-http-keepalive-maxsockets.js
  3. 5
      test/simple/test-http-keepalive-request.js

5
test/simple/test-http-agent-keepalive.js

@ -29,7 +29,7 @@ var agent = new Agent({
keepAlive: true, keepAlive: true,
keepAliveMsecs: 1000, keepAliveMsecs: 1000,
maxSockets: 5, maxSockets: 5,
maxFreeSockets: 5, maxFreeSockets: 5
}); });
var server = http.createServer(function (req, res) { var server = http.createServer(function (req, res) {
@ -47,9 +47,10 @@ var server = http.createServer(function (req, res) {
}); });
function get(path, callback) { function get(path, callback) {
return agent.get({ return http.get({
host: 'localhost', host: 'localhost',
port: common.PORT, port: common.PORT,
agent: agent,
path: path path: path
}, callback); }, callback);
} }

8
test/simple/test-http-keepalive-maxsockets.js

@ -44,7 +44,7 @@ var agent = http.Agent({
// then 10 more when they all finish. // then 10 more when they all finish.
function makeReqs(n, cb) { function makeReqs(n, cb) {
for (var i = 0; i < n; i++) for (var i = 0; i < n; i++)
makeReq(i, then) makeReq(i, then);
function then(er) { function then(er) {
if (er) if (er)
@ -55,7 +55,11 @@ function makeReqs(n, cb) {
} }
function makeReq(i, 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 = ''; var data = '';
res.setEncoding('ascii'); res.setEncoding('ascii');
res.on('data', function(c) { res.on('data', function(c) {

5
test/simple/test-http-keepalive-request.js

@ -54,9 +54,10 @@ function makeRequest(n) {
return; return;
} }
var req = agent.request({ var req = http.request({
port: common.PORT, port: common.PORT,
path: '/' + n path: '/' + n,
agent: agent
}); });
req.end(); req.end();

Loading…
Cancel
Save