mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

PR-URL: https://github.com/nodejs/node/pull/8622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: Jackson Tian <shvyo1987@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
36 lines
861 B
JavaScript
36 lines
861 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var fs = require('fs');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
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 body = 'hello world\n';
|
|
|
|
var httpsServer = https.createServer(options, function(req, res) {
|
|
res.on('finish', function() {
|
|
assert.strictEqual(typeof req.connection.bytesWritten, 'number');
|
|
assert(req.connection.bytesWritten > 0);
|
|
httpsServer.close();
|
|
console.log('ok');
|
|
});
|
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
res.end(body);
|
|
});
|
|
|
|
httpsServer.listen(0, function() {
|
|
https.get({
|
|
port: this.address().port,
|
|
rejectUnauthorized: false
|
|
});
|
|
});
|