From 7dfbccf9bdfe1d4d0e9df7e1be232fdb8507bda2 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 21 Jan 2011 15:55:48 -0800 Subject: [PATCH] Add test-https-agent --- test/simple/test-https-agent.js | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/simple/test-https-agent.js diff --git a/test/simple/test-https-agent.js b/test/simple/test-https-agent.js new file mode 100644 index 0000000000..669aa03780 --- /dev/null +++ b/test/simple/test-https-agent.js @@ -0,0 +1,46 @@ +if (!process.versions.openssl) { + console.error("Skipping because node compiled without OpenSSL."); + process.exit(0); +} + +var common = require('../common'); +var assert = require('assert'); +var https = require('https'); +var fs = require('fs'); + +var options = { + key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), + cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') +}; + + +var server = https.Server(options, function(req, res) { + res.writeHead(200); + res.end("hello world\n"); +}); + + +var responses = 0; +var N = 10; +var M = 10; + +server.listen(common.PORT, function() { + for (var i = 0; i < N; i++) { + setTimeout(function () { + for (var j = 0; j < M; j++) { + https.get({ port: common.PORT, path: '/', }, function(res) { + console.log(res.statusCode); + if (++responses == N * M) server.close(); + }).on('error', function(e) { + console.log(e.message); + process.exit(1); + }); + } + }, i); + } +}); + + +process.on('exit', function() { + assert.equal(N * M, responses); +});