2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2013-02-21 10:28:51 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 21:34:52 +02:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 17:25:55 +02:00
|
|
|
return;
|
2015-03-04 02:11:21 +01:00
|
|
|
}
|
2013-02-21 10:28:51 +01:00
|
|
|
var https = require('https');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
2013-02-21 10:28:51 +01:00
|
|
|
var Buffer = require('buffer').Buffer;
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
|
|
|
|
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
|
|
|
|
};
|
|
|
|
|
2016-01-26 00:00:06 +01:00
|
|
|
var buf = Buffer.allocUnsafe(1024 * 1024);
|
2013-02-21 10:28:51 +01:00
|
|
|
|
|
|
|
var server = https.createServer(options, function(req, res) {
|
|
|
|
res.writeHead(200);
|
|
|
|
for (var i = 0; i < 50; i++) {
|
|
|
|
res.write(buf);
|
|
|
|
}
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(common.PORT, function() {
|
|
|
|
var req = https.request({
|
|
|
|
method: 'POST',
|
|
|
|
port: common.PORT,
|
|
|
|
rejectUnauthorized: false
|
|
|
|
}, function(res) {
|
|
|
|
res.read(0);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// Read buffer should be somewhere near high watermark
|
|
|
|
// (i.e. should not leak)
|
|
|
|
assert(res._readableState.length < 100 * 1024);
|
|
|
|
process.exit(0);
|
2013-07-29 11:33:01 +02:00
|
|
|
}, 2000);
|
2013-02-21 10:28:51 +01:00
|
|
|
});
|
|
|
|
req.end();
|
|
|
|
});
|