diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-02-03 12:17:26 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-02-03 12:20:19 -0800 |
commit | 97f7c0645118ffb3844fec67345ad0ae7e71f6a9 (patch) | |
tree | 65d6e83c4c5bf600758572f6e84144c93d195bdb /test/pummel | |
parent | 3e58696c07161ef84c6b12aeb7e03d271563dcb9 (diff) | |
download | node-new-97f7c0645118ffb3844fec67345ad0ae7e71f6a9.tar.gz |
TLS: fix throttling
Re-enable test-https-large-response.js
Closes GH-614.
Diffstat (limited to 'test/pummel')
-rw-r--r-- | test/pummel/test-https-large-response.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/pummel/test-https-large-response.js b/test/pummel/test-https-large-response.js new file mode 100644 index 0000000000..625606dc62 --- /dev/null +++ b/test/pummel/test-https-large-response.js @@ -0,0 +1,66 @@ +var common = require('../common'); +var assert = require('assert'); + +var fs = require('fs'); +var https = require('https'); + +var options = { + key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), + cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') +}; + +var reqCount = 0; +var body = ''; + +process.stdout.write('build body...'); +for (var i = 0; i < 1024*1024; i++) { + body += 'hello world\n'; +} +process.stdout.write('done\n'); + +var server = https.createServer(options, function (req, res) { + reqCount++; + console.log('got request'); + res.writeHead(200, { 'content-type': 'text/plain' }); + res.end(body); +}); + +var count = 0; +var gotResEnd = false; + +var timeout = setTimeout(function() { + process.exit(1); +}, 10*1000); + +server.listen(common.PORT, function () { + https.get({ port: common.PORT }, function(res) { + console.log("response!"); + + res.on('data', function(d) { + process.stdout.write('.'); + count += d.length; + res.pause(); + process.nextTick(function () { + res.resume(); + }); + }); + + res.on('end', function(d) { + process.stdout.write('\n'); + console.log("expected: ", body.length); + console.log(" got: ", count); + server.close(); + gotResEnd = true; + + clearTimeout(timeout); + }); + }); +}); + + +process.on('exit', function () { + assert.equal(1, reqCount); + assert.equal(body.length, count); + assert.ok(gotResEnd); +}); + |